新增网络中转服务器+designer源码项目
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 243 KiB |
Before Width: | Height: | Size: 3.1 MiB After Width: | Height: | Size: 3.1 MiB |
Before Width: | Height: | Size: 428 KiB After Width: | Height: | Size: 428 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 545 KiB After Width: | Height: | Size: 545 KiB |
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
After Width: | Height: | Size: 233 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 360 KiB After Width: | Height: | Size: 360 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 339 KiB After Width: | Height: | Size: 339 KiB |
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 412 KiB After Width: | Height: | Size: 412 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 378 KiB After Width: | Height: | Size: 378 KiB |
Before Width: | Height: | Size: 667 KiB After Width: | Height: | Size: 667 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 226 KiB |
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 128 KiB |
Before Width: | Height: | Size: 638 KiB After Width: | Height: | Size: 638 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 840 KiB After Width: | Height: | Size: 840 KiB |
After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 401 KiB After Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 357 KiB After Width: | Height: | Size: 357 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 471 KiB After Width: | Height: | Size: 471 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
74
README.md
|
@ -36,44 +36,48 @@
|
||||||
| 33 | imageswitch | 图片开关控件 |
|
| 33 | imageswitch | 图片开关控件 |
|
||||||
| 34 | ffmpegdemo | 视频流播放ffmpeg内核 |
|
| 34 | ffmpegdemo | 视频流播放ffmpeg内核 |
|
||||||
| 35 | vlcdemo | 视频流播放vlc内核 |
|
| 35 | vlcdemo | 视频流播放vlc内核 |
|
||||||
|
| 36 | netserver | 网络中转服务器 |
|
||||||
|
| 37 | designer | QtDesigner4源码 |
|
||||||
|
|
||||||
### 二、学习群
|
### 二、学习群
|
||||||
1. **Qt交流大会群 853086607(雨田哥)**
|
1. **Qt交流大会群 853086607(雨田哥)**
|
||||||
2. **Qt技术交流群 46679801(3000人群)**
|
2. **Qt技术交流群 46679801(3000人群)**
|
||||||
|
|
||||||
### 三、效果图
|
### 三、效果图
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/lightbutton.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/lightbutton.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/movewidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/movewidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/flatui.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/flatui.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/countcode.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/countcode.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/gifwidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/gifwidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/comtool.jpg)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/comtool.jpg)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/nettool.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/nettool.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/devicesizetable.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/devicesizetable.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/styledemo_psblack.png)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/styledemo_psblack.png)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/styledemo_lightblue.png)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/styledemo_lightblue.png)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/styledemo_flatwhite.png)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/styledemo_flatwhite.png)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/navbutton.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/navbutton.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/videopanel.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/videopanel.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/framelesswidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/framelesswidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/ipaddress.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/ipaddress.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/bgdemo.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/bgdemo.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/dbpage.png)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/dbpage.png)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/pngtool.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/pngtool.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/colorwidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/colorwidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/maskwidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/maskwidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/battery.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/battery.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/lineeditnext.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/lineeditnext.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/zhtopy.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/zhtopy.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/qwtdemo.jpg)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/qwtdemo.jpg)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/buttondefence.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/buttondefence.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/mouseline.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/mouseline.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/emailtool.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/emailtool.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/ntpclient.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/ntpclient.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/lunarcalendarwidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/lunarcalendarwidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/videowidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/videowidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/screenwidget.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/screenwidget.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/echartgauge.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/echartgauge.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/imageswitch.gif)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/imageswitch.gif)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/ffmpegdemo.png)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/ffmpegdemo.png)
|
||||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/snap/vlcdemo.png)
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/vlcdemo.png)
|
||||||
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/netserver.jpg)
|
||||||
|
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/designer.png)
|
|
@ -0,0 +1,429 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "appfontdialog.h"
|
||||||
|
|
||||||
|
#include <iconloader_p.h>
|
||||||
|
#include <abstractsettings_p.h>
|
||||||
|
|
||||||
|
#include <QtGui/QTreeView>
|
||||||
|
#include <QtGui/QToolButton>
|
||||||
|
#include <QtGui/QHBoxLayout>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QSpacerItem>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtGui/QStandardItemModel>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QFontDatabase>
|
||||||
|
#include <QtGui/QDialogButtonBox>
|
||||||
|
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QtAlgorithms>
|
||||||
|
#include <QtCore/QVector>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
enum {FileNameRole = Qt::UserRole + 1, IdRole = Qt::UserRole + 2 };
|
||||||
|
enum { debugAppFontWidget = 0 };
|
||||||
|
|
||||||
|
static const char fontFileKeyC[] = "fontFiles";
|
||||||
|
|
||||||
|
// AppFontManager: Singleton that maintains the mapping of loaded application font
|
||||||
|
// ids to the file names (which are not stored in QFontDatabase)
|
||||||
|
// and provides API for loading/unloading fonts as well for saving/restoring settings.
|
||||||
|
|
||||||
|
class AppFontManager
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(AppFontManager)
|
||||||
|
AppFontManager();
|
||||||
|
public:
|
||||||
|
static AppFontManager &instance();
|
||||||
|
|
||||||
|
void save(QDesignerSettingsInterface *s, const QString &prefix) const;
|
||||||
|
void restore(const QDesignerSettingsInterface *s, const QString &prefix);
|
||||||
|
|
||||||
|
// Return id or -1
|
||||||
|
int add(const QString &fontFile, QString *errorMessage);
|
||||||
|
|
||||||
|
bool remove(int id, QString *errorMessage);
|
||||||
|
bool remove(const QString &fontFile, QString *errorMessage);
|
||||||
|
bool removeAt(int index, QString *errorMessage);
|
||||||
|
|
||||||
|
// Store loaded fonts as pair of file name and Id
|
||||||
|
typedef QPair<QString,int> FileNameFontIdPair;
|
||||||
|
typedef QList<FileNameFontIdPair> FileNameFontIdPairs;
|
||||||
|
const FileNameFontIdPairs &fonts() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FileNameFontIdPairs m_fonts;
|
||||||
|
};
|
||||||
|
|
||||||
|
AppFontManager::AppFontManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AppFontManager &AppFontManager::instance()
|
||||||
|
{
|
||||||
|
static AppFontManager rc;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontManager::save(QDesignerSettingsInterface *s, const QString &prefix) const
|
||||||
|
{
|
||||||
|
// Store as list of file names
|
||||||
|
QStringList fontFiles;
|
||||||
|
const FileNameFontIdPairs::const_iterator cend = m_fonts.constEnd();
|
||||||
|
for (FileNameFontIdPairs::const_iterator it = m_fonts.constBegin(); it != cend; ++it)
|
||||||
|
fontFiles.push_back(it->first);
|
||||||
|
|
||||||
|
s->beginGroup(prefix);
|
||||||
|
s->setValue(QLatin1String(fontFileKeyC), fontFiles);
|
||||||
|
s->endGroup();
|
||||||
|
|
||||||
|
if (debugAppFontWidget)
|
||||||
|
qDebug() << "AppFontManager::saved" << fontFiles.size() << "fonts under " << prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontManager::restore(const QDesignerSettingsInterface *s, const QString &prefix)
|
||||||
|
{
|
||||||
|
QString key = prefix;
|
||||||
|
key += QLatin1Char('/');
|
||||||
|
key += QLatin1String(fontFileKeyC);
|
||||||
|
const QStringList fontFiles = s->value(key, QStringList()).toStringList();
|
||||||
|
|
||||||
|
if (debugAppFontWidget)
|
||||||
|
qDebug() << "AppFontManager::restoring" << fontFiles.size() << "fonts from " << prefix;
|
||||||
|
if (!fontFiles.empty()) {
|
||||||
|
QString errorMessage;
|
||||||
|
const QStringList::const_iterator cend = fontFiles.constEnd();
|
||||||
|
for (QStringList::const_iterator it = fontFiles.constBegin(); it != cend; ++it)
|
||||||
|
if (add(*it, &errorMessage) == -1)
|
||||||
|
qWarning("%s", qPrintable(errorMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppFontManager::add(const QString &fontFile, QString *errorMessage)
|
||||||
|
{
|
||||||
|
const QFileInfo inf(fontFile);
|
||||||
|
if (!inf.isFile()) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AppFontManager", "'%1' is not a file.").arg(fontFile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!inf.isReadable()) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AppFontManager", "The font file '%1' does not have read permissions.").arg(fontFile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
const QString fullPath = inf.absoluteFilePath();
|
||||||
|
// Check if already loaded
|
||||||
|
const FileNameFontIdPairs::const_iterator cend = m_fonts.constEnd();
|
||||||
|
for (FileNameFontIdPairs::const_iterator it = m_fonts.constBegin(); it != cend; ++it) {
|
||||||
|
if (it->first == fullPath) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AppFontManager", "The font file '%1' is already loaded.").arg(fontFile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int id = QFontDatabase::addApplicationFont(fullPath);
|
||||||
|
if (id == -1) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AppFontManager", "The font file '%1' could not be loaded.").arg(fontFile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debugAppFontWidget)
|
||||||
|
qDebug() << "AppFontManager::add" << fontFile << id;
|
||||||
|
m_fonts.push_back(FileNameFontIdPair(fullPath, id));
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppFontManager::remove(int id, QString *errorMessage)
|
||||||
|
{
|
||||||
|
const int count = m_fonts.size();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
if (m_fonts[i].second == id)
|
||||||
|
return removeAt(i, errorMessage);
|
||||||
|
|
||||||
|
*errorMessage = QCoreApplication::translate("AppFontManager", "'%1' is not a valid font id.").arg(id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppFontManager::remove(const QString &fontFile, QString *errorMessage)
|
||||||
|
{
|
||||||
|
const int count = m_fonts.size();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
if (m_fonts[i].first == fontFile)
|
||||||
|
return removeAt(i, errorMessage);
|
||||||
|
|
||||||
|
*errorMessage = QCoreApplication::translate("AppFontManager", "There is no loaded font matching the id '%1'.").arg(fontFile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppFontManager::removeAt(int index, QString *errorMessage)
|
||||||
|
{
|
||||||
|
Q_ASSERT(index >= 0 && index < m_fonts.size());
|
||||||
|
|
||||||
|
const QString fontFile = m_fonts[index].first;
|
||||||
|
const int id = m_fonts[index].second;
|
||||||
|
|
||||||
|
if (debugAppFontWidget)
|
||||||
|
qDebug() << "AppFontManager::removeAt" << index << '(' << fontFile << id << ')';
|
||||||
|
|
||||||
|
if (!QFontDatabase::removeApplicationFont(id)) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AppFontManager", "The font '%1' (%2) could not be unloaded.").arg(fontFile).arg(id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_fonts.removeAt(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppFontManager::FileNameFontIdPairs &AppFontManager::fonts() const
|
||||||
|
{
|
||||||
|
return m_fonts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------- AppFontModel
|
||||||
|
class AppFontModel : public QStandardItemModel {
|
||||||
|
Q_DISABLE_COPY(AppFontModel)
|
||||||
|
public:
|
||||||
|
AppFontModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
void init(const AppFontManager &mgr);
|
||||||
|
void add(const QString &fontFile, int id);
|
||||||
|
int idAt(const QModelIndex &idx) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
AppFontModel::AppFontModel(QObject * parent) :
|
||||||
|
QStandardItemModel(parent)
|
||||||
|
{
|
||||||
|
setHorizontalHeaderLabels(QStringList(AppFontWidget::tr("Fonts")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontModel::init(const AppFontManager &mgr)
|
||||||
|
{
|
||||||
|
typedef AppFontManager::FileNameFontIdPairs FileNameFontIdPairs;
|
||||||
|
|
||||||
|
const FileNameFontIdPairs &fonts = mgr.fonts();
|
||||||
|
const FileNameFontIdPairs::const_iterator cend = fonts.constEnd();
|
||||||
|
for (FileNameFontIdPairs::const_iterator it = fonts.constBegin(); it != cend; ++it)
|
||||||
|
add(it->first, it->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontModel::add(const QString &fontFile, int id)
|
||||||
|
{
|
||||||
|
const QFileInfo inf(fontFile);
|
||||||
|
// Root item with base name
|
||||||
|
QStandardItem *fileItem = new QStandardItem(inf.completeBaseName());
|
||||||
|
const QString fullPath = inf.absoluteFilePath();
|
||||||
|
fileItem->setData(fullPath, FileNameRole);
|
||||||
|
fileItem->setToolTip(fullPath);
|
||||||
|
fileItem->setData(id, IdRole);
|
||||||
|
fileItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
|
||||||
|
|
||||||
|
appendRow(fileItem);
|
||||||
|
const QStringList families = QFontDatabase::applicationFontFamilies(id);
|
||||||
|
const QStringList::const_iterator cend = families.constEnd();
|
||||||
|
for (QStringList::const_iterator it = families.constBegin(); it != cend; ++it) {
|
||||||
|
QStandardItem *familyItem = new QStandardItem(*it);
|
||||||
|
familyItem->setToolTip(fullPath);
|
||||||
|
familyItem->setFont(QFont(*it));
|
||||||
|
familyItem->setFlags(Qt::ItemIsEnabled);
|
||||||
|
fileItem->appendRow(familyItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppFontModel::idAt(const QModelIndex &idx) const
|
||||||
|
{
|
||||||
|
if (const QStandardItem *item = itemFromIndex(idx))
|
||||||
|
return item->data(IdRole).toInt();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------- AppFontWidget
|
||||||
|
AppFontWidget::AppFontWidget(QWidget *parent) :
|
||||||
|
QGroupBox(parent),
|
||||||
|
m_view(new QTreeView),
|
||||||
|
m_addButton(new QToolButton),
|
||||||
|
m_removeButton(new QToolButton),
|
||||||
|
m_removeAllButton(new QToolButton),
|
||||||
|
m_model(new AppFontModel(this))
|
||||||
|
{
|
||||||
|
m_model->init(AppFontManager::instance());
|
||||||
|
m_view->setModel(m_model);
|
||||||
|
m_view->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
m_view->expandAll();
|
||||||
|
connect(m_view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection)));
|
||||||
|
|
||||||
|
m_addButton->setToolTip(tr("Add font files"));
|
||||||
|
m_addButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("plus.png")));
|
||||||
|
connect(m_addButton, SIGNAL(clicked()), this, SLOT(addFiles()));
|
||||||
|
|
||||||
|
m_removeButton->setEnabled(false);
|
||||||
|
m_removeButton->setToolTip(tr("Remove current font file"));
|
||||||
|
m_removeButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("minus.png")));
|
||||||
|
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveFiles()));
|
||||||
|
|
||||||
|
m_removeAllButton->setToolTip(tr("Remove all font files"));
|
||||||
|
m_removeAllButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("editdelete.png")));
|
||||||
|
connect(m_removeAllButton, SIGNAL(clicked()), this, SLOT(slotRemoveAll()));
|
||||||
|
|
||||||
|
QHBoxLayout *hLayout = new QHBoxLayout;
|
||||||
|
hLayout->addWidget(m_addButton);
|
||||||
|
hLayout->addWidget(m_removeButton);
|
||||||
|
hLayout->addWidget(m_removeAllButton);
|
||||||
|
hLayout->addItem(new QSpacerItem(0, 0,QSizePolicy::MinimumExpanding));
|
||||||
|
|
||||||
|
QVBoxLayout *vLayout = new QVBoxLayout;
|
||||||
|
vLayout->addWidget(m_view);
|
||||||
|
vLayout->addLayout(hLayout);
|
||||||
|
setLayout(vLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontWidget::addFiles()
|
||||||
|
{
|
||||||
|
const QStringList files =
|
||||||
|
QFileDialog::getOpenFileNames(this, tr("Add Font Files"), QString(),
|
||||||
|
tr("Font files (*.ttf)"));
|
||||||
|
if (files.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString errorMessage;
|
||||||
|
|
||||||
|
AppFontManager &fmgr = AppFontManager::instance();
|
||||||
|
const QStringList::const_iterator cend = files.constEnd();
|
||||||
|
for (QStringList::const_iterator it = files.constBegin(); it != cend; ++it) {
|
||||||
|
const int id = fmgr.add(*it, &errorMessage);
|
||||||
|
if (id != -1) {
|
||||||
|
m_model->add(*it, id);
|
||||||
|
} else {
|
||||||
|
QMessageBox::critical(this, tr("Error Adding Fonts"), errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_view->expandAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void removeFonts(const QModelIndexList &selectedIndexes, AppFontModel *model, QWidget *dialogParent)
|
||||||
|
{
|
||||||
|
if (selectedIndexes.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Reverse sort top level rows and remove
|
||||||
|
AppFontManager &fmgr = AppFontManager::instance();
|
||||||
|
QVector<int> rows;
|
||||||
|
rows.reserve(selectedIndexes.size());
|
||||||
|
|
||||||
|
QString errorMessage;
|
||||||
|
const QModelIndexList::const_iterator cend = selectedIndexes.constEnd();
|
||||||
|
for (QModelIndexList::const_iterator it = selectedIndexes.constBegin(); it != cend; ++it) {
|
||||||
|
const int id = model->idAt(*it);
|
||||||
|
if (id != -1) {
|
||||||
|
if (fmgr.remove(id, &errorMessage)) {
|
||||||
|
rows.push_back(it->row());
|
||||||
|
} else {
|
||||||
|
QMessageBox::critical(dialogParent, AppFontWidget::tr("Error Removing Fonts"), errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qStableSort(rows.begin(), rows.end());
|
||||||
|
for (int i = rows.size() - 1; i >= 0; i--)
|
||||||
|
model->removeRow(rows[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontWidget::slotRemoveFiles()
|
||||||
|
{
|
||||||
|
removeFonts(m_view->selectionModel()->selectedIndexes(), m_model, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontWidget::slotRemoveAll()
|
||||||
|
{
|
||||||
|
const int count = m_model->rowCount();
|
||||||
|
if (!count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QMessageBox::StandardButton answer =
|
||||||
|
QMessageBox::question(this, tr("Remove Fonts"), tr("Would you like to remove all fonts?"),
|
||||||
|
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
|
||||||
|
if (answer == QMessageBox::No)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QModelIndexList topLevels;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
topLevels.push_back(m_model->index(i, 0));
|
||||||
|
removeFonts(topLevels, m_model, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontWidget::selectionChanged(const QItemSelection &selected, const QItemSelection & /*deselected*/)
|
||||||
|
{
|
||||||
|
m_removeButton->setEnabled(!selected.indexes().empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontWidget::save(QDesignerSettingsInterface *s, const QString &prefix)
|
||||||
|
{
|
||||||
|
AppFontManager::instance().save(s, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppFontWidget::restore(const QDesignerSettingsInterface *s, const QString &prefix)
|
||||||
|
{
|
||||||
|
AppFontManager::instance().restore(s, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------ AppFontDialog
|
||||||
|
AppFontDialog::AppFontDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
m_appFontWidget(new AppFontWidget)
|
||||||
|
{
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
setWindowTitle(tr("Additional Fonts"));
|
||||||
|
setModal(false);
|
||||||
|
QVBoxLayout *vl = new QVBoxLayout;
|
||||||
|
vl->addWidget(m_appFontWidget);
|
||||||
|
|
||||||
|
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||||
|
QDialog::connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
vl->addWidget(bb);
|
||||||
|
setLayout(vl);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,101 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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_APPFONTWIDGET_H
|
||||||
|
#define QDESIGNER_APPFONTWIDGET_H
|
||||||
|
|
||||||
|
#include <QtGui/QGroupBox>
|
||||||
|
#include <QtGui/QDialog>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class AppFontModel;
|
||||||
|
|
||||||
|
class QTreeView;
|
||||||
|
class QToolButton;
|
||||||
|
class QItemSelection;
|
||||||
|
class QDesignerSettingsInterface;
|
||||||
|
|
||||||
|
// AppFontWidget: Manages application fonts which the user can load and
|
||||||
|
// provides API for saving/restoring them.
|
||||||
|
|
||||||
|
class AppFontWidget : public QGroupBox
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(AppFontWidget)
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit AppFontWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
|
QStringList fontFiles() const;
|
||||||
|
|
||||||
|
static void save(QDesignerSettingsInterface *s, const QString &prefix);
|
||||||
|
static void restore(const QDesignerSettingsInterface *s, const QString &prefix);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void addFiles();
|
||||||
|
void slotRemoveFiles();
|
||||||
|
void slotRemoveAll();
|
||||||
|
void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTreeView *m_view;
|
||||||
|
QToolButton *m_addButton;
|
||||||
|
QToolButton *m_removeButton;
|
||||||
|
QToolButton *m_removeAllButton;
|
||||||
|
AppFontModel *m_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
// AppFontDialog: Non modal dialog for AppFontWidget which has Qt::WA_DeleteOnClose set.
|
||||||
|
|
||||||
|
class AppFontDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(AppFontDialog)
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit AppFontDialog(QWidget *parent = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AppFontWidget *m_appFontWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // QDESIGNER_APPFONTWIDGET_H
|
|
@ -0,0 +1,175 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "assistantclient.h"
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QProcess>
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QLibraryInfo>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QTextStream>
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
enum { debugAssistantClient = 0 };
|
||||||
|
|
||||||
|
AssistantClient::AssistantClient() :
|
||||||
|
m_process(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AssistantClient::~AssistantClient()
|
||||||
|
{
|
||||||
|
if (isRunning()) {
|
||||||
|
m_process->terminate();
|
||||||
|
m_process->waitForFinished();
|
||||||
|
}
|
||||||
|
delete m_process;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AssistantClient::showPage(const QString &path, QString *errorMessage)
|
||||||
|
{
|
||||||
|
QString cmd = QLatin1String("SetSource ");
|
||||||
|
cmd += path;
|
||||||
|
return sendCommand(cmd, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AssistantClient::activateIdentifier(const QString &identifier, QString *errorMessage)
|
||||||
|
{
|
||||||
|
QString cmd = QLatin1String("ActivateIdentifier ");
|
||||||
|
cmd += identifier;
|
||||||
|
return sendCommand(cmd, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AssistantClient::activateKeyword(const QString &keyword, QString *errorMessage)
|
||||||
|
{
|
||||||
|
QString cmd = QLatin1String("ActivateKeyword ");
|
||||||
|
cmd += keyword;
|
||||||
|
return sendCommand(cmd, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AssistantClient::sendCommand(const QString &cmd, QString *errorMessage)
|
||||||
|
{
|
||||||
|
if (debugAssistantClient)
|
||||||
|
qDebug() << "sendCommand " << cmd;
|
||||||
|
if (!ensureRunning(errorMessage))
|
||||||
|
return false;
|
||||||
|
if (!m_process->isWritable() || m_process->bytesToWrite() > 0) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AssistantClient", "Unable to send request: Assistant is not responding.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QTextStream str(m_process);
|
||||||
|
str << cmd << QLatin1Char('\n') << endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AssistantClient::isRunning() const
|
||||||
|
{
|
||||||
|
return m_process && m_process->state() != QProcess::NotRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AssistantClient::binary()
|
||||||
|
{
|
||||||
|
QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
|
||||||
|
#if !defined(Q_OS_MAC)
|
||||||
|
app += QLatin1String("assistant");
|
||||||
|
#else
|
||||||
|
app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
app += QLatin1String(".exe");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AssistantClient::ensureRunning(QString *errorMessage)
|
||||||
|
{
|
||||||
|
if (isRunning())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!m_process)
|
||||||
|
m_process = new QProcess;
|
||||||
|
|
||||||
|
const QString app = binary();
|
||||||
|
if (!QFileInfo(app).isFile()) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AssistantClient", "The binary '%1' does not exist.").arg(app);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (debugAssistantClient)
|
||||||
|
qDebug() << "Running " << app;
|
||||||
|
// run
|
||||||
|
QStringList args(QLatin1String("-enableRemoteControl"));
|
||||||
|
m_process->start(app, args);
|
||||||
|
if (!m_process->waitForStarted()) {
|
||||||
|
*errorMessage = QCoreApplication::translate("AssistantClient", "Unable to launch assistant (%1).").arg(app);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AssistantClient::documentUrl(const QString &prefix, int qtVersion)
|
||||||
|
{
|
||||||
|
if (qtVersion == 0)
|
||||||
|
qtVersion = QT_VERSION;
|
||||||
|
QString rc;
|
||||||
|
QTextStream(&rc) << QLatin1String("qthelp://com.trolltech.") << prefix << QLatin1Char('.')
|
||||||
|
<< (qtVersion >> 16) << ((qtVersion >> 8) & 0xFF) << (qtVersion & 0xFF)
|
||||||
|
<< QLatin1String("/qdoc/");
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AssistantClient::designerManualUrl(int qtVersion)
|
||||||
|
{
|
||||||
|
return documentUrl(QLatin1String("designer"), qtVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AssistantClient::qtReferenceManualUrl(int qtVersion)
|
||||||
|
{
|
||||||
|
return documentUrl(QLatin1String("qt"), qtVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,83 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 ASSISTANTCLIENT_H
|
||||||
|
#define ASSISTANTCLIENT_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QProcess;
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
class AssistantClient
|
||||||
|
{
|
||||||
|
AssistantClient(const AssistantClient &);
|
||||||
|
AssistantClient &operator=(const AssistantClient &);
|
||||||
|
|
||||||
|
public:
|
||||||
|
AssistantClient();
|
||||||
|
~AssistantClient();
|
||||||
|
|
||||||
|
bool showPage(const QString &path, QString *errorMessage);
|
||||||
|
bool activateIdentifier(const QString &identifier, QString *errorMessage);
|
||||||
|
bool activateKeyword(const QString &keyword, QString *errorMessage);
|
||||||
|
|
||||||
|
bool isRunning() const;
|
||||||
|
|
||||||
|
static QString documentUrl(const QString &prefix, int qtVersion = 0);
|
||||||
|
// Root of the Qt Designer documentation
|
||||||
|
static QString designerManualUrl(int qtVersion = 0);
|
||||||
|
// Root of the Qt Reference documentation
|
||||||
|
static QString qtReferenceManualUrl(int qtVersion = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QString binary();
|
||||||
|
bool sendCommand(const QString &cmd, QString *errorMessage);
|
||||||
|
bool ensureRunning(QString *errorMessage);
|
||||||
|
|
||||||
|
QProcess *m_process;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // ASSISTANTCLIENT_H
|
|
@ -0,0 +1,69 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2017-04-07T09:15:51
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += xml network
|
||||||
|
CONFIG += warn_off release
|
||||||
|
RESOURCES += designer.qrc
|
||||||
|
LIBS += -lQtDesignerComponents -lQtDesigner
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
INCLUDEPATH += ../lib/sdk ../lib/extension ../lib/shared ../lib/uilib
|
||||||
|
|
||||||
|
TARGET = designer
|
||||||
|
TEMPLATE = app
|
||||||
|
MOC_DIR = temp/moc
|
||||||
|
RCC_DIR = temp/rcc
|
||||||
|
UI_DIR = temp/ui
|
||||||
|
OBJECTS_DIR = temp/obj
|
||||||
|
DESTDIR = bin
|
||||||
|
TRANSLATIONS = designer_zh_CN.ts
|
||||||
|
PRECOMPILED_HEADER = qdesigner_pch.h
|
||||||
|
win32:RC_FILE = main.rc
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
qdesigner.h \
|
||||||
|
qdesigner_toolwindow.h \
|
||||||
|
qdesigner_formwindow.h \
|
||||||
|
qdesigner_workbench.h \
|
||||||
|
qdesigner_settings.h \
|
||||||
|
qdesigner_actions.h \
|
||||||
|
qdesigner_server.h \
|
||||||
|
qdesigner_appearanceoptions.h \
|
||||||
|
saveformastemplate.h \
|
||||||
|
newform.h \
|
||||||
|
versiondialog.h \
|
||||||
|
designer_enums.h \
|
||||||
|
appfontdialog.h \
|
||||||
|
preferencesdialog.h \
|
||||||
|
assistantclient.h \
|
||||||
|
mainwindow.h \
|
||||||
|
qttoolbardialog.h \
|
||||||
|
fontpanel.h
|
||||||
|
|
||||||
|
SOURCES += main.cpp \
|
||||||
|
qdesigner.cpp \
|
||||||
|
qdesigner_toolwindow.cpp \
|
||||||
|
qdesigner_formwindow.cpp \
|
||||||
|
qdesigner_workbench.cpp \
|
||||||
|
qdesigner_settings.cpp \
|
||||||
|
qdesigner_server.cpp \
|
||||||
|
qdesigner_actions.cpp \
|
||||||
|
qdesigner_appearanceoptions.cpp \
|
||||||
|
saveformastemplate.cpp \
|
||||||
|
newform.cpp \
|
||||||
|
versiondialog.cpp \
|
||||||
|
appfontdialog.cpp \
|
||||||
|
preferencesdialog.cpp \
|
||||||
|
assistantclient.cpp \
|
||||||
|
mainwindow.cpp \
|
||||||
|
qttoolbardialog.cpp \
|
||||||
|
fontpanel.cpp
|
||||||
|
|
||||||
|
FORMS += saveformastemplate.ui \
|
||||||
|
preferencesdialog.ui \
|
||||||
|
qdesigner_appearanceoptions.ui \
|
||||||
|
qttoolbardialog.ui
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/trolltech/designer">
|
||||||
|
<file>images/designer.png</file>
|
||||||
|
<file>images/back.png</file>
|
||||||
|
<file>images/down.png</file>
|
||||||
|
<file>images/forward.png</file>
|
||||||
|
<file>images/minus.png</file>
|
||||||
|
<file>images/plus.png</file>
|
||||||
|
<file>images/up.png</file>
|
||||||
|
<file>images/designer_zh_CN.qm</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
|
@ -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
|
|
@ -0,0 +1,308 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 tools applications 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 "fontpanel.h"
|
||||||
|
|
||||||
|
#include <QtGui/QLabel>
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
|
#include <QtGui/QFormLayout>
|
||||||
|
#include <QtGui/QSpacerItem>
|
||||||
|
#include <QtGui/QFontComboBox>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
#include <QtGui/QLineEdit>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
FontPanel::FontPanel(QWidget *parentWidget) :
|
||||||
|
QGroupBox(parentWidget),
|
||||||
|
m_previewLineEdit(new QLineEdit),
|
||||||
|
m_writingSystemComboBox(new QComboBox),
|
||||||
|
m_familyComboBox(new QFontComboBox),
|
||||||
|
m_styleComboBox(new QComboBox),
|
||||||
|
m_pointSizeComboBox(new QComboBox),
|
||||||
|
m_previewFontUpdateTimer(0)
|
||||||
|
{
|
||||||
|
setTitle(tr("Font"));
|
||||||
|
|
||||||
|
QFormLayout *formLayout = new QFormLayout(this);
|
||||||
|
// writing systems
|
||||||
|
m_writingSystemComboBox->setEditable(false);
|
||||||
|
|
||||||
|
QList<QFontDatabase::WritingSystem> writingSystems = m_fontDatabase.writingSystems();
|
||||||
|
writingSystems.push_front(QFontDatabase::Any);
|
||||||
|
foreach (QFontDatabase::WritingSystem ws, writingSystems)
|
||||||
|
m_writingSystemComboBox->addItem(QFontDatabase::writingSystemName(ws), QVariant(ws));
|
||||||
|
connect(m_writingSystemComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotWritingSystemChanged(int)));
|
||||||
|
formLayout->addRow(tr("&Writing system"), m_writingSystemComboBox);
|
||||||
|
|
||||||
|
connect(m_familyComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(slotFamilyChanged(QFont)));
|
||||||
|
formLayout->addRow(tr("&Family"), m_familyComboBox);
|
||||||
|
|
||||||
|
m_styleComboBox->setEditable(false);
|
||||||
|
connect(m_styleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotStyleChanged(int)));
|
||||||
|
formLayout->addRow(tr("&Style"), m_styleComboBox);
|
||||||
|
|
||||||
|
m_pointSizeComboBox->setEditable(false);
|
||||||
|
connect(m_pointSizeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotPointSizeChanged(int)));
|
||||||
|
formLayout->addRow(tr("&Point size"), m_pointSizeComboBox);
|
||||||
|
|
||||||
|
m_previewLineEdit->setReadOnly(true);
|
||||||
|
formLayout->addRow(m_previewLineEdit);
|
||||||
|
|
||||||
|
setWritingSystem(QFontDatabase::Any);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont FontPanel::selectedFont() const
|
||||||
|
{
|
||||||
|
QFont rc = m_familyComboBox->currentFont();
|
||||||
|
const QString family = rc.family();
|
||||||
|
rc.setPointSize(pointSize());
|
||||||
|
const QString styleDescription = styleString();
|
||||||
|
if (styleDescription.contains(QLatin1String("Italic")))
|
||||||
|
rc.setStyle(QFont::StyleItalic);
|
||||||
|
else if (styleDescription.contains(QLatin1String("Oblique")))
|
||||||
|
rc.setStyle(QFont::StyleOblique);
|
||||||
|
else
|
||||||
|
rc.setStyle(QFont::StyleNormal);
|
||||||
|
rc.setBold(m_fontDatabase.bold(family, styleDescription));
|
||||||
|
|
||||||
|
// Weight < 0 asserts...
|
||||||
|
const int weight = m_fontDatabase.weight(family, styleDescription);
|
||||||
|
if (weight >= 0)
|
||||||
|
rc.setWeight(weight);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::setSelectedFont(const QFont &f)
|
||||||
|
{
|
||||||
|
m_familyComboBox->setCurrentFont(f);
|
||||||
|
if (m_familyComboBox->currentIndex() < 0) {
|
||||||
|
// family not in writing system - find the corresponding one?
|
||||||
|
QList<QFontDatabase::WritingSystem> familyWritingSystems = m_fontDatabase.writingSystems(f.family());
|
||||||
|
if (familyWritingSystems.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
setWritingSystem(familyWritingSystems.front());
|
||||||
|
m_familyComboBox->setCurrentFont(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFamily(family());
|
||||||
|
|
||||||
|
const int pointSizeIndex = closestPointSizeIndex(f.pointSize());
|
||||||
|
m_pointSizeComboBox->setCurrentIndex( pointSizeIndex);
|
||||||
|
|
||||||
|
const QString styleString = m_fontDatabase.styleString(f);
|
||||||
|
const int styleIndex = m_styleComboBox->findText(styleString);
|
||||||
|
m_styleComboBox->setCurrentIndex(styleIndex);
|
||||||
|
slotUpdatePreviewFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QFontDatabase::WritingSystem FontPanel::writingSystem() const
|
||||||
|
{
|
||||||
|
const int currentIndex = m_writingSystemComboBox->currentIndex();
|
||||||
|
if ( currentIndex == -1)
|
||||||
|
return QFontDatabase::Latin;
|
||||||
|
return static_cast<QFontDatabase::WritingSystem>(m_writingSystemComboBox->itemData(currentIndex).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FontPanel::family() const
|
||||||
|
{
|
||||||
|
const int currentIndex = m_familyComboBox->currentIndex();
|
||||||
|
return currentIndex != -1 ? m_familyComboBox->currentFont().family() : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
int FontPanel::pointSize() const
|
||||||
|
{
|
||||||
|
const int currentIndex = m_pointSizeComboBox->currentIndex();
|
||||||
|
return currentIndex != -1 ? m_pointSizeComboBox->itemData(currentIndex).toInt() : 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FontPanel::styleString() const
|
||||||
|
{
|
||||||
|
const int currentIndex = m_styleComboBox->currentIndex();
|
||||||
|
return currentIndex != -1 ? m_styleComboBox->itemText(currentIndex) : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::setWritingSystem(QFontDatabase::WritingSystem ws)
|
||||||
|
{
|
||||||
|
m_writingSystemComboBox->setCurrentIndex(m_writingSystemComboBox->findData(QVariant(ws)));
|
||||||
|
updateWritingSystem(ws);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FontPanel::slotWritingSystemChanged(int)
|
||||||
|
{
|
||||||
|
updateWritingSystem(writingSystem());
|
||||||
|
delayedPreviewFontUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::slotFamilyChanged(const QFont &)
|
||||||
|
{
|
||||||
|
updateFamily(family());
|
||||||
|
delayedPreviewFontUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::slotStyleChanged(int)
|
||||||
|
{
|
||||||
|
updatePointSizes(family(), styleString());
|
||||||
|
delayedPreviewFontUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::slotPointSizeChanged(int)
|
||||||
|
{
|
||||||
|
delayedPreviewFontUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::updateWritingSystem(QFontDatabase::WritingSystem ws)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_previewLineEdit->setText(QFontDatabase::writingSystemSample(ws));
|
||||||
|
m_familyComboBox->setWritingSystem (ws);
|
||||||
|
// Current font not in WS ... set index 0.
|
||||||
|
if (m_familyComboBox->currentIndex() < 0) {
|
||||||
|
m_familyComboBox->setCurrentIndex(0);
|
||||||
|
updateFamily(family());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::updateFamily(const QString &family)
|
||||||
|
{
|
||||||
|
// Update styles and trigger update of point sizes.
|
||||||
|
// Try to maintain selection or select normal
|
||||||
|
const QString oldStyleString = styleString();
|
||||||
|
|
||||||
|
const QStringList styles = m_fontDatabase.styles(family);
|
||||||
|
const bool hasStyles = !styles.empty();
|
||||||
|
|
||||||
|
m_styleComboBox->setCurrentIndex(-1);
|
||||||
|
m_styleComboBox->clear();
|
||||||
|
m_styleComboBox->setEnabled(hasStyles);
|
||||||
|
|
||||||
|
int normalIndex = -1;
|
||||||
|
const QString normalStyle = QLatin1String("Normal");
|
||||||
|
|
||||||
|
if (hasStyles) {
|
||||||
|
foreach (const QString &style, styles) {
|
||||||
|
// try to maintain selection or select 'normal' preferably
|
||||||
|
const int newIndex = m_styleComboBox->count();
|
||||||
|
m_styleComboBox->addItem(style);
|
||||||
|
if (oldStyleString == style) {
|
||||||
|
m_styleComboBox->setCurrentIndex(newIndex);
|
||||||
|
} else {
|
||||||
|
if (oldStyleString == normalStyle)
|
||||||
|
normalIndex = newIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_styleComboBox->currentIndex() == -1 && normalIndex != -1)
|
||||||
|
m_styleComboBox->setCurrentIndex(normalIndex);
|
||||||
|
}
|
||||||
|
updatePointSizes(family, styleString());
|
||||||
|
}
|
||||||
|
|
||||||
|
int FontPanel::closestPointSizeIndex(int desiredPointSize) const
|
||||||
|
{
|
||||||
|
// try to maintain selection or select closest.
|
||||||
|
int closestIndex = -1;
|
||||||
|
int closestAbsError = 0xFFFF;
|
||||||
|
|
||||||
|
const int pointSizeCount = m_pointSizeComboBox->count();
|
||||||
|
for (int i = 0; i < pointSizeCount; i++) {
|
||||||
|
const int itemPointSize = m_pointSizeComboBox->itemData(i).toInt();
|
||||||
|
const int absError = qAbs(desiredPointSize - itemPointSize);
|
||||||
|
if (absError < closestAbsError) {
|
||||||
|
closestIndex = i;
|
||||||
|
closestAbsError = absError;
|
||||||
|
if (closestAbsError == 0)
|
||||||
|
break;
|
||||||
|
} else { // past optimum
|
||||||
|
if (absError > closestAbsError) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return closestIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FontPanel::updatePointSizes(const QString &family, const QString &styleString)
|
||||||
|
{
|
||||||
|
const int oldPointSize = pointSize();
|
||||||
|
|
||||||
|
QList<int> pointSizes = m_fontDatabase.pointSizes(family, styleString);
|
||||||
|
if (pointSizes.empty())
|
||||||
|
pointSizes = QFontDatabase::standardSizes();
|
||||||
|
|
||||||
|
const bool hasSizes = !pointSizes.empty();
|
||||||
|
m_pointSizeComboBox->clear();
|
||||||
|
m_pointSizeComboBox->setEnabled(hasSizes);
|
||||||
|
m_pointSizeComboBox->setCurrentIndex(-1);
|
||||||
|
|
||||||
|
// try to maintain selection or select closest.
|
||||||
|
if (hasSizes) {
|
||||||
|
QString n;
|
||||||
|
foreach (int pointSize, pointSizes)
|
||||||
|
m_pointSizeComboBox->addItem(n.setNum(pointSize), QVariant(pointSize));
|
||||||
|
const int closestIndex = closestPointSizeIndex(oldPointSize);
|
||||||
|
if (closestIndex != -1)
|
||||||
|
m_pointSizeComboBox->setCurrentIndex(closestIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::slotUpdatePreviewFont()
|
||||||
|
{
|
||||||
|
m_previewLineEdit->setFont(selectedFont());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontPanel::delayedPreviewFontUpdate()
|
||||||
|
{
|
||||||
|
if (!m_previewFontUpdateTimer) {
|
||||||
|
m_previewFontUpdateTimer = new QTimer(this);
|
||||||
|
connect(m_previewFontUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdatePreviewFont()));
|
||||||
|
m_previewFontUpdateTimer->setInterval(0);
|
||||||
|
m_previewFontUpdateTimer->setSingleShot(true);
|
||||||
|
}
|
||||||
|
if (m_previewFontUpdateTimer->isActive())
|
||||||
|
return;
|
||||||
|
m_previewFontUpdateTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,108 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 tools applications 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$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G
|
||||||
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is not part of the Qt API. It exists for the convenience
|
||||||
|
// of the Qt tools. This header
|
||||||
|
// file may change from version to version without notice, or even be removed.
|
||||||
|
//
|
||||||
|
// We mean it.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef FONTPANEL_H
|
||||||
|
#define FONTPANEL_H
|
||||||
|
|
||||||
|
#include <QtGui/QGroupBox>
|
||||||
|
#include <QtGui/QFont>
|
||||||
|
#include <QtGui/QFontDatabase>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QComboBox;
|
||||||
|
class QFontComboBox;
|
||||||
|
class QTimer;
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
|
class FontPanel: public QGroupBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
FontPanel(QWidget *parentWidget = 0);
|
||||||
|
|
||||||
|
QFont selectedFont() const;
|
||||||
|
void setSelectedFont(const QFont &);
|
||||||
|
|
||||||
|
QFontDatabase::WritingSystem writingSystem() const;
|
||||||
|
void setWritingSystem(QFontDatabase::WritingSystem ws);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotWritingSystemChanged(int);
|
||||||
|
void slotFamilyChanged(const QFont &);
|
||||||
|
void slotStyleChanged(int);
|
||||||
|
void slotPointSizeChanged(int);
|
||||||
|
void slotUpdatePreviewFont();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString family() const;
|
||||||
|
QString styleString() const;
|
||||||
|
int pointSize() const;
|
||||||
|
int closestPointSizeIndex(int ps) const;
|
||||||
|
|
||||||
|
void updateWritingSystem(QFontDatabase::WritingSystem ws);
|
||||||
|
void updateFamily(const QString &family);
|
||||||
|
void updatePointSizes(const QString &family, const QString &style);
|
||||||
|
void delayedPreviewFontUpdate();
|
||||||
|
|
||||||
|
QFontDatabase m_fontDatabase;
|
||||||
|
QLineEdit *m_previewLineEdit;
|
||||||
|
QComboBox *m_writingSystemComboBox;
|
||||||
|
QFontComboBox* m_familyComboBox;
|
||||||
|
QComboBox *m_styleComboBox;
|
||||||
|
QComboBox *m_pointSizeComboBox;
|
||||||
|
QTimer *m_previewFontUpdateTimer;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // FONTPANEL_H
|
After Width: | Height: | Size: 678 B |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 594 B |
After Width: | Height: | Size: 655 B |
After Width: | Height: | Size: 250 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 692 B |
|
@ -0,0 +1,73 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 <QtCore/QLibraryInfo>
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
Q_INIT_RESOURCE(designer);
|
||||||
|
|
||||||
|
QDesigner app(argc, argv);
|
||||||
|
app.setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
|
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
|
||||||
|
#if _MSC_VER
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("gbk");
|
||||||
|
#else
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("utf-8");
|
||||||
|
#endif
|
||||||
|
QTextCodec::setCodecForLocale(codec);
|
||||||
|
QTextCodec::setCodecForCStrings(codec);
|
||||||
|
QTextCodec::setCodecForTr(codec);
|
||||||
|
#else
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("utf-8");
|
||||||
|
QTextCodec::setCodecForLocale(codec);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
After Width: | Height: | Size: 66 KiB |
|
@ -0,0 +1,41 @@
|
||||||
|
# if defined(UNDER_CE)
|
||||||
|
# include <winbase.h>
|
||||||
|
# else
|
||||||
|
# include <windows.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
IDI_ICON1 ICON DISCARDABLE "main.ico"
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION 2018,8,26,0
|
||||||
|
PRODUCTVERSION 2018,8,26,0
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS VS_FF_DEBUG
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS VOS__WINDOWS32
|
||||||
|
FILETYPE VFT_DLL
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", "feiyangqingyun QQ:517216493\0"
|
||||||
|
VALUE "FileDescription", "Qt Designer\0"
|
||||||
|
VALUE "FileVersion", "2018.8.26.0\0"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) 2018\0"
|
||||||
|
VALUE "OriginalFilename", "designer.exe\0"
|
||||||
|
VALUE "ProductName", "designer\0"
|
||||||
|
VALUE "ProductVersion", "2018.8.26.0\0"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x0409, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
/* End of Version info */
|
||||||
|
|
|
@ -0,0 +1,419 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "mainwindow.h"
|
||||||
|
#include "qdesigner.h"
|
||||||
|
#include "qdesigner_actions.h"
|
||||||
|
#include "qdesigner_workbench.h"
|
||||||
|
#include "qdesigner_formwindow.h"
|
||||||
|
#include "qdesigner_toolwindow.h"
|
||||||
|
#include "qdesigner_settings.h"
|
||||||
|
#include "qttoolbardialog.h"
|
||||||
|
|
||||||
|
#include <QtDesigner/QDesignerFormWindowInterface>
|
||||||
|
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QCloseEvent>
|
||||||
|
#include <QtGui/QToolBar>
|
||||||
|
#include <QtGui/QMdiSubWindow>
|
||||||
|
#include <QtGui/QStatusBar>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QLayout>
|
||||||
|
#include <QtGui/QDockWidget>
|
||||||
|
|
||||||
|
#include <QtCore/QUrl>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
static const char *uriListMimeFormatC = "text/uri-list";
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
typedef QList<QAction *> ActionList;
|
||||||
|
|
||||||
|
// Helpers for creating toolbars and menu
|
||||||
|
|
||||||
|
static void addActionsToToolBar(const ActionList &actions, QToolBar *t)
|
||||||
|
{
|
||||||
|
const ActionList::const_iterator cend = actions.constEnd();
|
||||||
|
for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) {
|
||||||
|
QAction *action = *it;
|
||||||
|
if (action->property(QDesignerActions::defaultToolbarPropertyName).toBool())
|
||||||
|
t->addAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static QToolBar *createToolBar(const QString &title, const QString &objectName, const ActionList &actions)
|
||||||
|
{
|
||||||
|
QToolBar *rc = new QToolBar;
|
||||||
|
rc->setObjectName(objectName);
|
||||||
|
rc->setWindowTitle(title);
|
||||||
|
addActionsToToolBar(actions, rc);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- MainWindowBase
|
||||||
|
|
||||||
|
MainWindowBase::MainWindowBase(QWidget *parent, Qt::WindowFlags flags) :
|
||||||
|
QMainWindow(parent, flags),
|
||||||
|
m_policy(AcceptCloseEvents)
|
||||||
|
{
|
||||||
|
#ifndef Q_WS_MAC
|
||||||
|
setWindowIcon(qDesigner->windowIcon());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowBase::closeEvent(QCloseEvent *e)
|
||||||
|
{
|
||||||
|
switch (m_policy) {
|
||||||
|
case AcceptCloseEvents:
|
||||||
|
QMainWindow::closeEvent(e);
|
||||||
|
break;
|
||||||
|
case EmitCloseEventSignal:
|
||||||
|
emit closeEventReceived(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QToolBar *> MainWindowBase::createToolBars(const QDesignerActions *actions, bool singleToolBar)
|
||||||
|
{
|
||||||
|
// Note that whenever you want to add a new tool bar here, you also have to update the default
|
||||||
|
// action groups added to the toolbar manager in the mainwindow constructor
|
||||||
|
QList<QToolBar *> rc;
|
||||||
|
if (singleToolBar) {
|
||||||
|
//: Not currently used (main tool bar)
|
||||||
|
QToolBar *main = createToolBar(tr("Main"), QLatin1String("mainToolBar"), actions->fileActions()->actions());
|
||||||
|
addActionsToToolBar(actions->editActions()->actions(), main);
|
||||||
|
addActionsToToolBar(actions->toolActions()->actions(), main);
|
||||||
|
addActionsToToolBar(actions->formActions()->actions(), main);
|
||||||
|
rc.push_back(main);
|
||||||
|
} else {
|
||||||
|
rc.push_back(createToolBar(tr("File"), QLatin1String("fileToolBar"), actions->fileActions()->actions()));
|
||||||
|
rc.push_back(createToolBar(tr("Edit"), QLatin1String("editToolBar"), actions->editActions()->actions()));
|
||||||
|
rc.push_back(createToolBar(tr("Tools"), QLatin1String("toolsToolBar"), actions->toolActions()->actions()));
|
||||||
|
rc.push_back(createToolBar(tr("Form"), QLatin1String("formToolBar"), actions->formActions()->actions()));
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MainWindowBase::mainWindowTitle()
|
||||||
|
{
|
||||||
|
return tr("Qt Designer");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the minor Qt version as settings versions to avoid conflicts
|
||||||
|
int MainWindowBase::settingsVersion()
|
||||||
|
{
|
||||||
|
const int version = QT_VERSION;
|
||||||
|
return (version & 0x00FF00) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------- DockedMdiArea
|
||||||
|
|
||||||
|
DockedMdiArea::DockedMdiArea(const QString &extension, QWidget *parent) :
|
||||||
|
QMdiArea(parent),
|
||||||
|
m_extension(extension)
|
||||||
|
{
|
||||||
|
setAcceptDrops(true);
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList DockedMdiArea::uiFiles(const QMimeData *d) const
|
||||||
|
{
|
||||||
|
// Extract dropped UI files from Mime data.
|
||||||
|
QStringList rc;
|
||||||
|
if (!d->hasFormat(QLatin1String(uriListMimeFormatC)))
|
||||||
|
return rc;
|
||||||
|
const QList<QUrl> urls = d->urls();
|
||||||
|
if (urls.empty())
|
||||||
|
return rc;
|
||||||
|
const QList<QUrl>::const_iterator cend = urls.constEnd();
|
||||||
|
for (QList<QUrl>::const_iterator it = urls.constBegin(); it != cend; ++it) {
|
||||||
|
const QString fileName = it->toLocalFile();
|
||||||
|
if (!fileName.isEmpty() && fileName.endsWith(m_extension))
|
||||||
|
rc.push_back(fileName);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DockedMdiArea::event(QEvent *event)
|
||||||
|
{
|
||||||
|
// Listen for desktop file manager drop and emit a signal once a file is
|
||||||
|
// dropped.
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::DragEnter: {
|
||||||
|
QDragEnterEvent *e = static_cast<QDragEnterEvent*>(event);
|
||||||
|
if (!uiFiles(e->mimeData()).empty()) {
|
||||||
|
e->acceptProposedAction();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEvent::Drop: {
|
||||||
|
QDropEvent *e = static_cast<QDropEvent*>(event);
|
||||||
|
const QStringList files = uiFiles(e->mimeData());
|
||||||
|
const QStringList::const_iterator cend = files.constEnd();
|
||||||
|
for (QStringList::const_iterator it = files.constBegin(); it != cend; ++it) {
|
||||||
|
emit fileDropped(*it);
|
||||||
|
}
|
||||||
|
e->acceptProposedAction();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QMdiArea::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------- ToolBarManager:
|
||||||
|
|
||||||
|
static void addActionsToToolBarManager(const ActionList &al, const QString &title, QtToolBarManager *tbm)
|
||||||
|
{
|
||||||
|
const ActionList::const_iterator cend = al.constEnd();
|
||||||
|
for (ActionList::const_iterator it = al.constBegin(); it != cend; ++it)
|
||||||
|
tbm->addAction(*it, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolBarManager::ToolBarManager(QMainWindow *configureableMainWindow,
|
||||||
|
QWidget *parent,
|
||||||
|
QMenu *toolBarMenu,
|
||||||
|
const QDesignerActions *actions,
|
||||||
|
const QList<QToolBar *> &toolbars,
|
||||||
|
const QList<QDesignerToolWindow*> &toolWindows) :
|
||||||
|
QObject(parent),
|
||||||
|
m_configureableMainWindow(configureableMainWindow),
|
||||||
|
m_parent(parent),
|
||||||
|
m_toolBarMenu(toolBarMenu),
|
||||||
|
m_manager(new QtToolBarManager(this)),
|
||||||
|
m_configureAction(new QAction(tr("Configure Toolbars..."), this)),
|
||||||
|
m_toolbars(toolbars)
|
||||||
|
{
|
||||||
|
m_configureAction->setMenuRole(QAction::NoRole);
|
||||||
|
m_configureAction->setObjectName(QLatin1String("__qt_configure_tool_bars_action"));
|
||||||
|
connect(m_configureAction, SIGNAL(triggered()), this, SLOT(configureToolBars()));
|
||||||
|
|
||||||
|
m_manager->setMainWindow(configureableMainWindow);
|
||||||
|
|
||||||
|
foreach(QToolBar *tb, m_toolbars) {
|
||||||
|
const QString title = tb->windowTitle();
|
||||||
|
m_manager->addToolBar(tb, title);
|
||||||
|
addActionsToToolBarManager(tb->actions(), title, m_manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
addActionsToToolBarManager(actions->windowActions()->actions(), tr("Window"), m_manager);
|
||||||
|
addActionsToToolBarManager(actions->helpActions()->actions(), tr("Help"), m_manager);
|
||||||
|
|
||||||
|
// Filter out the device profile preview actions which have int data().
|
||||||
|
ActionList previewActions = actions->styleActions()->actions();
|
||||||
|
ActionList::iterator it = previewActions.begin();
|
||||||
|
for ( ; (*it)->isSeparator() || (*it)->data().type() == QVariant::Int; ++it) ;
|
||||||
|
previewActions.erase(previewActions.begin(), it);
|
||||||
|
addActionsToToolBarManager(previewActions, tr("Style"), m_manager);
|
||||||
|
|
||||||
|
const QString dockTitle = tr("Dock views");
|
||||||
|
foreach (QDesignerToolWindow *tw, toolWindows) {
|
||||||
|
if (QAction *action = tw->action())
|
||||||
|
m_manager->addAction(action, dockTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString category(tr("File"));
|
||||||
|
foreach(QAction *action, actions->fileActions()->actions())
|
||||||
|
m_manager->addAction(action, category);
|
||||||
|
|
||||||
|
category = tr("Edit");
|
||||||
|
foreach(QAction *action, actions->editActions()->actions())
|
||||||
|
m_manager->addAction(action, category);
|
||||||
|
|
||||||
|
category = tr("Tools");
|
||||||
|
foreach(QAction *action, actions->toolActions()->actions())
|
||||||
|
m_manager->addAction(action, category);
|
||||||
|
|
||||||
|
category = tr("Form");
|
||||||
|
foreach(QAction *action, actions->formActions()->actions())
|
||||||
|
m_manager->addAction(action, category);
|
||||||
|
|
||||||
|
m_manager->addAction(m_configureAction, tr("Toolbars"));
|
||||||
|
updateToolBarMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort function for sorting tool bars alphabetically by title [non-static since called from template]
|
||||||
|
|
||||||
|
bool toolBarTitleLessThan(const QToolBar *t1, const QToolBar *t2)
|
||||||
|
{
|
||||||
|
return t1->windowTitle() < t2->windowTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBarManager::updateToolBarMenu()
|
||||||
|
{
|
||||||
|
// Sort tool bars alphabetically by title
|
||||||
|
qStableSort(m_toolbars.begin(), m_toolbars.end(), toolBarTitleLessThan);
|
||||||
|
// add to menu
|
||||||
|
m_toolBarMenu->clear();
|
||||||
|
foreach (QToolBar *tb, m_toolbars)
|
||||||
|
m_toolBarMenu->addAction(tb->toggleViewAction());
|
||||||
|
m_toolBarMenu->addAction(m_configureAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBarManager::configureToolBars()
|
||||||
|
{
|
||||||
|
// QtToolBarDialog dlg(m_parent);
|
||||||
|
// dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
// dlg.setToolBarManager(m_manager);
|
||||||
|
// dlg.exec();
|
||||||
|
// updateToolBarMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray ToolBarManager::saveState(int version) const
|
||||||
|
{
|
||||||
|
return m_manager->saveState(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ToolBarManager::restoreState(const QByteArray &state, int version)
|
||||||
|
{
|
||||||
|
return m_manager->restoreState(state, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- DockedMainWindow
|
||||||
|
|
||||||
|
DockedMainWindow::DockedMainWindow(QDesignerWorkbench *wb,
|
||||||
|
QMenu *toolBarMenu,
|
||||||
|
const QList<QDesignerToolWindow*> &toolWindows) :
|
||||||
|
m_toolBarManager(0)
|
||||||
|
{
|
||||||
|
setObjectName(QLatin1String("MDIWindow"));
|
||||||
|
setWindowTitle(mainWindowTitle());
|
||||||
|
|
||||||
|
const QList<QToolBar *> toolbars = createToolBars(wb->actionManager(), false);
|
||||||
|
foreach (QToolBar *tb, toolbars)
|
||||||
|
addToolBar(tb);
|
||||||
|
DockedMdiArea *dma = new DockedMdiArea(wb->actionManager()->uiExtension());
|
||||||
|
connect(dma, SIGNAL(fileDropped(QString)),
|
||||||
|
this, SIGNAL(fileDropped(QString)));
|
||||||
|
connect(dma, SIGNAL(subWindowActivated(QMdiSubWindow*)),
|
||||||
|
this, SLOT(slotSubWindowActivated(QMdiSubWindow*)));
|
||||||
|
setCentralWidget(dma);
|
||||||
|
|
||||||
|
QStatusBar *sb = statusBar();
|
||||||
|
Q_UNUSED(sb)
|
||||||
|
|
||||||
|
m_toolBarManager = new ToolBarManager(this, this, toolBarMenu, wb->actionManager(), toolbars, toolWindows);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMdiArea *DockedMainWindow::mdiArea() const
|
||||||
|
{
|
||||||
|
return static_cast<QMdiArea *>(centralWidget());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockedMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
|
||||||
|
{
|
||||||
|
if (subWindow) {
|
||||||
|
QWidget *widget = subWindow->widget();
|
||||||
|
if (QDesignerFormWindow *fw = qobject_cast<QDesignerFormWindow*>(widget)) {
|
||||||
|
emit formWindowActivated(fw);
|
||||||
|
mdiArea()->setActiveSubWindow(subWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a MDI subwindow for the form.
|
||||||
|
QMdiSubWindow *DockedMainWindow::createMdiSubWindow(QWidget *fw, Qt::WindowFlags f, const QKeySequence &designerCloseActionShortCut)
|
||||||
|
{
|
||||||
|
QMdiSubWindow *rc = mdiArea()->addSubWindow(fw, f);
|
||||||
|
// Make action shortcuts respond only if focused to avoid conflicts with
|
||||||
|
// designer menu actions
|
||||||
|
if (designerCloseActionShortCut == QKeySequence(QKeySequence::Close)) {
|
||||||
|
const ActionList systemMenuActions = rc->systemMenu()->actions();
|
||||||
|
if (!systemMenuActions.empty()) {
|
||||||
|
const ActionList::const_iterator cend = systemMenuActions.constEnd();
|
||||||
|
for (ActionList::const_iterator it = systemMenuActions.constBegin(); it != cend; ++it) {
|
||||||
|
if ( (*it)->shortcut() == designerCloseActionShortCut) {
|
||||||
|
(*it)->setShortcutContext(Qt::WidgetShortcut);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
DockedMainWindow::DockWidgetList DockedMainWindow::addToolWindows(const DesignerToolWindowList &tls)
|
||||||
|
{
|
||||||
|
DockWidgetList rc;
|
||||||
|
foreach (QDesignerToolWindow *tw, tls) {
|
||||||
|
QDockWidget *dockWidget = new QDockWidget;
|
||||||
|
dockWidget->setObjectName(tw->objectName() + QLatin1String("_dock"));
|
||||||
|
dockWidget->setWindowTitle(tw->windowTitle());
|
||||||
|
addDockWidget(tw->dockWidgetAreaHint(), dockWidget);
|
||||||
|
dockWidget->setWidget(tw);
|
||||||
|
rc.push_back(dockWidget);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Settings consist of MainWindow state and tool bar manager state
|
||||||
|
void DockedMainWindow::restoreSettings(const QDesignerSettings &s, const DockWidgetList &dws, const QRect &desktopArea)
|
||||||
|
{
|
||||||
|
const int version = settingsVersion();
|
||||||
|
m_toolBarManager->restoreState(s.toolBarsState(DockedMode), version);
|
||||||
|
|
||||||
|
// If there are no old geometry settings, show the window maximized
|
||||||
|
s.restoreGeometry(this, QRect(desktopArea.topLeft(), QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)));
|
||||||
|
|
||||||
|
const QByteArray mainWindowState = s.mainWindowState(DockedMode);
|
||||||
|
const bool restored = !mainWindowState.isEmpty() && restoreState(mainWindowState, version);
|
||||||
|
if (!restored) {
|
||||||
|
// Default: Tabify less relevant windows bottom/right.
|
||||||
|
tabifyDockWidget(dws.at(QDesignerToolWindow::SignalSlotEditor),
|
||||||
|
dws.at(QDesignerToolWindow::ActionEditor));
|
||||||
|
tabifyDockWidget(dws.at(QDesignerToolWindow::ActionEditor),
|
||||||
|
dws.at(QDesignerToolWindow::ResourceEditor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockedMainWindow::saveSettings(QDesignerSettings &s) const
|
||||||
|
{
|
||||||
|
const int version = settingsVersion();
|
||||||
|
s.setToolBarsState(DockedMode, m_toolBarManager->saveState(version));
|
||||||
|
s.saveGeometryFor(this);
|
||||||
|
s.setMainWindowState(DockedMode, saveState(version));
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,187 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QtGui/QMainWindow>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtGui/QMdiArea>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QDesignerActions;
|
||||||
|
class QDesignerWorkbench;
|
||||||
|
class QDesignerToolWindow;
|
||||||
|
class QDesignerFormWindow;
|
||||||
|
class QDesignerSettings;
|
||||||
|
|
||||||
|
class QtToolBarManager;
|
||||||
|
class QToolBar;
|
||||||
|
class QMdiArea;
|
||||||
|
class QMenu;
|
||||||
|
class QByteArray;
|
||||||
|
class QMimeData;
|
||||||
|
|
||||||
|
/* A main window that has a configureable policy on handling close events. If
|
||||||
|
* enabled, it can forward the close event to external handlers.
|
||||||
|
* Base class for windows that can switch roles between tool windows
|
||||||
|
* and main windows. */
|
||||||
|
|
||||||
|
class MainWindowBase: public QMainWindow
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(MainWindowBase)
|
||||||
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
explicit MainWindowBase(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Window);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum CloseEventPolicy {
|
||||||
|
/* Always accept close events */
|
||||||
|
AcceptCloseEvents,
|
||||||
|
/* Emit a signal with the event, have it handled elsewhere */
|
||||||
|
EmitCloseEventSignal };
|
||||||
|
|
||||||
|
CloseEventPolicy closeEventPolicy() const { return m_policy; }
|
||||||
|
void setCloseEventPolicy(CloseEventPolicy pol) { m_policy = pol; }
|
||||||
|
|
||||||
|
static QList<QToolBar *> createToolBars(const QDesignerActions *actions, bool singleToolBar);
|
||||||
|
static QString mainWindowTitle();
|
||||||
|
|
||||||
|
// Use the minor Qt version as settings versions to avoid conflicts
|
||||||
|
static int settingsVersion();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void closeEventReceived(QCloseEvent *e);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void closeEvent(QCloseEvent *e);
|
||||||
|
private:
|
||||||
|
CloseEventPolicy m_policy;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* An MdiArea that listens for desktop file manager file drop events and emits
|
||||||
|
* a signal to open a dropped file. */
|
||||||
|
class DockedMdiArea : public QMdiArea
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(DockedMdiArea)
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DockedMdiArea(const QString &extension, QWidget *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fileDropped(const QString &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool event (QEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList uiFiles(const QMimeData *d) const;
|
||||||
|
|
||||||
|
const QString m_extension;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convenience class that manages a QtToolBarManager and an action to trigger
|
||||||
|
// it on a mainwindow.
|
||||||
|
class ToolBarManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(ToolBarManager)
|
||||||
|
public:
|
||||||
|
explicit ToolBarManager(QMainWindow *configureableMainWindow,
|
||||||
|
QWidget *parent,
|
||||||
|
QMenu *toolBarMenu,
|
||||||
|
const QDesignerActions *actions,
|
||||||
|
const QList<QToolBar *> &toolbars,
|
||||||
|
const QList<QDesignerToolWindow*> &toolWindows);
|
||||||
|
|
||||||
|
QByteArray saveState(int version = 0) const;
|
||||||
|
bool restoreState(const QByteArray &state, int version = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void configureToolBars();
|
||||||
|
void updateToolBarMenu();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMainWindow *m_configureableMainWindow;
|
||||||
|
QWidget *m_parent;
|
||||||
|
QMenu *m_toolBarMenu;
|
||||||
|
QtToolBarManager *m_manager;
|
||||||
|
QAction *m_configureAction;
|
||||||
|
QList<QToolBar *> m_toolbars;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Main window to be used for docked mode */
|
||||||
|
class DockedMainWindow : public MainWindowBase {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(DockedMainWindow)
|
||||||
|
public:
|
||||||
|
typedef QList<QDesignerToolWindow*> DesignerToolWindowList;
|
||||||
|
typedef QList<QDockWidget *> DockWidgetList;
|
||||||
|
|
||||||
|
explicit DockedMainWindow(QDesignerWorkbench *wb,
|
||||||
|
QMenu *toolBarMenu,
|
||||||
|
const DesignerToolWindowList &toolWindows);
|
||||||
|
|
||||||
|
// Create a MDI subwindow for the form.
|
||||||
|
QMdiSubWindow *createMdiSubWindow(QWidget *fw, Qt::WindowFlags f, const QKeySequence &designerCloseActionShortCut);
|
||||||
|
|
||||||
|
QMdiArea *mdiArea() const;
|
||||||
|
|
||||||
|
DockWidgetList addToolWindows(const DesignerToolWindowList &toolWindows);
|
||||||
|
|
||||||
|
void restoreSettings(const QDesignerSettings &s, const DockWidgetList &dws, const QRect &desktopArea);
|
||||||
|
void saveSettings(QDesignerSettings &) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fileDropped(const QString &);
|
||||||
|
void formWindowActivated(QDesignerFormWindow *);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotSubWindowActivated(QMdiSubWindow*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ToolBarManager *m_toolBarManager;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
|
@ -0,0 +1,229 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "newform.h"
|
||||||
|
#include "qdesigner_workbench.h"
|
||||||
|
#include "qdesigner_actions.h"
|
||||||
|
#include "qdesigner_formwindow.h"
|
||||||
|
#include "qdesigner_settings.h"
|
||||||
|
|
||||||
|
#include <newformwidget_p.h>
|
||||||
|
|
||||||
|
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||||
|
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QTemporaryFile>
|
||||||
|
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
#include <QtGui/QDialogButtonBox>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QCheckBox>
|
||||||
|
#include <QtGui/QFrame>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
NewForm::NewForm(QDesignerWorkbench *workbench, QWidget *parentWidget, const QString &fileName)
|
||||||
|
: QDialog(parentWidget,
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
Qt::Tool |
|
||||||
|
#endif
|
||||||
|
Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
|
m_fileName(fileName),
|
||||||
|
m_newFormWidget(QDesignerNewFormWidgetInterface::createNewFormWidget(workbench->core())),
|
||||||
|
m_workbench(workbench),
|
||||||
|
m_chkShowOnStartup(new QCheckBox(tr("Show this Dialog on Startup"))),
|
||||||
|
m_createButton(new QPushButton(QApplication::translate("NewForm", "C&reate", 0, QApplication::UnicodeUTF8))),
|
||||||
|
m_recentButton(new QPushButton(QApplication::translate("NewForm", "Recent", 0, QApplication::UnicodeUTF8))),
|
||||||
|
m_buttonBox(0)
|
||||||
|
{
|
||||||
|
setWindowTitle(tr("New Form"));
|
||||||
|
QDesignerSettings settings(m_workbench->core());
|
||||||
|
|
||||||
|
QVBoxLayout *vBoxLayout = new QVBoxLayout;
|
||||||
|
|
||||||
|
connect(m_newFormWidget, SIGNAL(templateActivated()), this, SLOT(slotTemplateActivated()));
|
||||||
|
connect(m_newFormWidget, SIGNAL(currentTemplateChanged(bool)), this, SLOT(slotCurrentTemplateChanged(bool)));
|
||||||
|
vBoxLayout->addWidget(m_newFormWidget);
|
||||||
|
|
||||||
|
QFrame *horizontalLine = new QFrame;
|
||||||
|
horizontalLine->setFrameShape(QFrame::HLine);
|
||||||
|
horizontalLine->setFrameShadow(QFrame::Sunken);
|
||||||
|
vBoxLayout->addWidget(horizontalLine);
|
||||||
|
|
||||||
|
m_chkShowOnStartup->setChecked(settings.showNewFormOnStartup());
|
||||||
|
vBoxLayout->addWidget(m_chkShowOnStartup);
|
||||||
|
|
||||||
|
m_buttonBox = createButtonBox();
|
||||||
|
vBoxLayout->addWidget(m_buttonBox);
|
||||||
|
setLayout(vBoxLayout);
|
||||||
|
|
||||||
|
resize(500, 400);
|
||||||
|
slotCurrentTemplateChanged(m_newFormWidget->hasCurrentTemplate());
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialogButtonBox *NewForm::createButtonBox()
|
||||||
|
{
|
||||||
|
// Dialog buttons with 'recent files'
|
||||||
|
QDialogButtonBox *buttonBox = new QDialogButtonBox;
|
||||||
|
buttonBox->addButton(QApplication::translate("NewForm", "&Close", 0,
|
||||||
|
QApplication::UnicodeUTF8), QDialogButtonBox::RejectRole);
|
||||||
|
buttonBox->addButton(m_createButton, QDialogButtonBox::AcceptRole);
|
||||||
|
buttonBox->addButton(QApplication::translate("NewForm", "&Open...", 0,
|
||||||
|
QApplication::UnicodeUTF8), QDialogButtonBox::ActionRole);
|
||||||
|
buttonBox->addButton(m_recentButton, QDialogButtonBox::ActionRole);
|
||||||
|
|
||||||
|
QDesignerActions *da = m_workbench->actionManager();
|
||||||
|
|
||||||
|
QMenu *recentFilesMenu = new QMenu(tr("&Recent Forms"), m_recentButton);
|
||||||
|
// Pop the "Recent Files" stuff in here.
|
||||||
|
const QList<QAction *> recentActions = da->recentFilesActions()->actions();
|
||||||
|
if (!recentActions.empty()) {
|
||||||
|
const QList<QAction *>::const_iterator acend = recentActions.constEnd();
|
||||||
|
for (QList<QAction *>::const_iterator it = recentActions.constBegin(); it != acend; ++it) {
|
||||||
|
recentFilesMenu->addAction(*it);
|
||||||
|
connect(*it, SIGNAL(triggered()), this, SLOT(recentFileChosen()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_recentButton->setMenu(recentFilesMenu);
|
||||||
|
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotButtonBoxClicked(QAbstractButton*)));
|
||||||
|
return buttonBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
NewForm::~NewForm()
|
||||||
|
{
|
||||||
|
QDesignerSettings settings (m_workbench->core());
|
||||||
|
settings.setShowNewFormOnStartup(m_chkShowOnStartup->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewForm::recentFileChosen()
|
||||||
|
{
|
||||||
|
QAction *action = qobject_cast<QAction *>(sender());
|
||||||
|
if (!action)
|
||||||
|
return;
|
||||||
|
if (action->objectName() == QLatin1String("__qt_action_clear_menu_"))
|
||||||
|
return;
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewForm::slotCurrentTemplateChanged(bool templateSelected)
|
||||||
|
{
|
||||||
|
if (templateSelected) {
|
||||||
|
m_createButton->setEnabled(true);
|
||||||
|
m_createButton->setDefault(true);
|
||||||
|
} else {
|
||||||
|
m_createButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewForm::slotTemplateActivated()
|
||||||
|
{
|
||||||
|
m_createButton->animateClick(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewForm::slotButtonBoxClicked(QAbstractButton *btn)
|
||||||
|
{
|
||||||
|
switch (m_buttonBox->buttonRole(btn)) {
|
||||||
|
case QDialogButtonBox::RejectRole:
|
||||||
|
reject();
|
||||||
|
break;
|
||||||
|
case QDialogButtonBox::ActionRole:
|
||||||
|
if (btn != m_recentButton) {
|
||||||
|
m_fileName.clear();
|
||||||
|
if (m_workbench->actionManager()->openForm(this))
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QDialogButtonBox::AcceptRole: {
|
||||||
|
QString errorMessage;
|
||||||
|
if (openTemplate(&errorMessage)) {
|
||||||
|
accept();
|
||||||
|
} else {
|
||||||
|
QMessageBox::warning(this, tr("Read error"), errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NewForm::openTemplate(QString *ptrToErrorMessage)
|
||||||
|
{
|
||||||
|
const QString contents = m_newFormWidget->currentTemplate(ptrToErrorMessage);
|
||||||
|
if (contents.isEmpty())
|
||||||
|
return false;
|
||||||
|
// Write to temporary file and open
|
||||||
|
QString tempPattern = QDir::tempPath();
|
||||||
|
if (!tempPattern.endsWith(QDir::separator())) // platform-dependant
|
||||||
|
tempPattern += QDir::separator();
|
||||||
|
tempPattern += QLatin1String("XXXXXX.ui");
|
||||||
|
QTemporaryFile tempFormFile(tempPattern);
|
||||||
|
|
||||||
|
tempFormFile.setAutoRemove(true);
|
||||||
|
if (!tempFormFile.open()) {
|
||||||
|
*ptrToErrorMessage = tr("A temporary form file could not be created in %1.").arg(QDir::tempPath());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const QString tempFormFileName = tempFormFile.fileName();
|
||||||
|
tempFormFile.write(contents.toUtf8());
|
||||||
|
if (!tempFormFile.flush()) {
|
||||||
|
*ptrToErrorMessage = tr("The temporary form file %1 could not be written.").arg(tempFormFileName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
tempFormFile.close();
|
||||||
|
return m_workbench->openTemplate(tempFormFileName, m_fileName, ptrToErrorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage NewForm::grabForm(QDesignerFormEditorInterface *core,
|
||||||
|
QIODevice &file,
|
||||||
|
const QString &workingDir,
|
||||||
|
const qdesigner_internal::DeviceProfile &dp)
|
||||||
|
{
|
||||||
|
return qdesigner_internal::NewFormWidget::grabForm(core, file, workingDir, dp);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,104 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 NEWFORM_H
|
||||||
|
#define NEWFORM_H
|
||||||
|
|
||||||
|
#include <QtGui/QDialog>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace qdesigner_internal {
|
||||||
|
class DeviceProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
class QDesignerFormEditorInterface;
|
||||||
|
class QDesignerNewFormWidgetInterface;
|
||||||
|
class QDesignerWorkbench;
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
|
class QAbstractButton;
|
||||||
|
class QPushButton;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QImage;
|
||||||
|
class QIODevice;
|
||||||
|
|
||||||
|
class NewForm: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(NewForm)
|
||||||
|
|
||||||
|
public:
|
||||||
|
NewForm(QDesignerWorkbench *workbench,
|
||||||
|
QWidget *parentWidget,
|
||||||
|
// Use that file name instead of a temporary one
|
||||||
|
const QString &fileName = QString());
|
||||||
|
|
||||||
|
virtual ~NewForm();
|
||||||
|
|
||||||
|
// Convenience for implementing file dialogs with preview
|
||||||
|
static QImage grabForm(QDesignerFormEditorInterface *core,
|
||||||
|
QIODevice &file,
|
||||||
|
const QString &workingDir,
|
||||||
|
const qdesigner_internal::DeviceProfile &dp);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotButtonBoxClicked(QAbstractButton *btn);
|
||||||
|
void recentFileChosen();
|
||||||
|
void slotCurrentTemplateChanged(bool templateSelected);
|
||||||
|
void slotTemplateActivated();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDialogButtonBox *createButtonBox();
|
||||||
|
bool openTemplate(QString *ptrToErrorMessage);
|
||||||
|
|
||||||
|
QString m_fileName;
|
||||||
|
QDesignerNewFormWidgetInterface *m_newFormWidget;
|
||||||
|
QDesignerWorkbench *m_workbench;
|
||||||
|
QCheckBox *m_chkShowOnStartup;
|
||||||
|
QPushButton *m_createButton;
|
||||||
|
QPushButton *m_recentButton;
|
||||||
|
QDialogButtonBox *m_buttonBox;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // NEWFORM_H
|
|
@ -0,0 +1,118 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "preferencesdialog.h"
|
||||||
|
#include "ui_preferencesdialog.h"
|
||||||
|
#include "qdesigner_appearanceoptions.h"
|
||||||
|
|
||||||
|
#include <QtDesigner/private/abstractoptionspage_p.h>
|
||||||
|
|
||||||
|
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
PreferencesDialog::PreferencesDialog(QDesignerFormEditorInterface *core, QWidget *parentWidget) :
|
||||||
|
QDialog(parentWidget),
|
||||||
|
m_ui(new Ui::PreferencesDialog()),
|
||||||
|
m_core(core)
|
||||||
|
{
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
m_optionsPages = core->optionsPages();
|
||||||
|
|
||||||
|
m_ui->m_optionTabWidget->clear();
|
||||||
|
foreach (QDesignerOptionsPageInterface *optionsPage, m_optionsPages) {
|
||||||
|
QWidget *page = optionsPage->createPage(this);
|
||||||
|
m_ui->m_optionTabWidget->addTab(page, optionsPage->name());
|
||||||
|
if (QDesignerAppearanceOptionsWidget *appearanceWidget = qobject_cast<QDesignerAppearanceOptionsWidget *>(page))
|
||||||
|
connect(appearanceWidget, SIGNAL(uiModeChanged(bool)), this, SLOT(slotUiModeChanged(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(m_ui->m_dialogButtonBox, SIGNAL(rejected()), this, SLOT(slotRejected()));
|
||||||
|
connect(m_ui->m_dialogButtonBox, SIGNAL(accepted()), this, SLOT(slotAccepted()));
|
||||||
|
connect(applyButton(), SIGNAL(clicked()), this, SLOT(slotApply()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferencesDialog::~PreferencesDialog()
|
||||||
|
{
|
||||||
|
delete m_ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton *PreferencesDialog::applyButton() const
|
||||||
|
{
|
||||||
|
return m_ui->m_dialogButtonBox->button(QDialogButtonBox::Apply);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::slotApply()
|
||||||
|
{
|
||||||
|
foreach (QDesignerOptionsPageInterface *optionsPage, m_optionsPages)
|
||||||
|
optionsPage->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::slotAccepted()
|
||||||
|
{
|
||||||
|
slotApply();
|
||||||
|
closeOptionPages();
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::slotRejected()
|
||||||
|
{
|
||||||
|
closeOptionPages();
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::slotUiModeChanged(bool modified)
|
||||||
|
{
|
||||||
|
// Cannot "apply" a ui mode change (destroy the dialogs parent)
|
||||||
|
applyButton()->setEnabled(!modified);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::closeOptionPages()
|
||||||
|
{
|
||||||
|
foreach (QDesignerOptionsPageInterface *optionsPage, m_optionsPages)
|
||||||
|
optionsPage->finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,82 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 PREFERENCESDIALOG_H
|
||||||
|
#define PREFERENCESDIALOG_H
|
||||||
|
|
||||||
|
#include <QtGui/QDialog>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
class QDesignerFormEditorInterface;
|
||||||
|
class QDesignerOptionsPageInterface;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class PreferencesDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreferencesDialog: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit PreferencesDialog(QDesignerFormEditorInterface *core, QWidget *parentWidget = 0);
|
||||||
|
~PreferencesDialog();
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotAccepted();
|
||||||
|
void slotRejected();
|
||||||
|
void slotApply();
|
||||||
|
void slotUiModeChanged(bool modified);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPushButton *applyButton() const;
|
||||||
|
void closeOptionPages();
|
||||||
|
|
||||||
|
Ui::PreferencesDialog *m_ui;
|
||||||
|
QDesignerFormEditorInterface *m_core;
|
||||||
|
QList<QDesignerOptionsPageInterface*> m_optionsPages;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // PREFERENCESDIALOG_H
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>PreferencesDialog</class>
|
||||||
|
<widget class="QDialog" name="PreferencesDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>474</width>
|
||||||
|
<height>304</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Preferences</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="m_optionTabWidget">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string notr="true">Tab 1</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="m_dialogButtonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Apply|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_dialogButtonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>PreferencesDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_dialogButtonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>PreferencesDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
@ -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>
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,138 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 tools applications 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$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G
|
||||||
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is not part of the Qt API. It exists for the convenience
|
||||||
|
// of Qt Designer. This header
|
||||||
|
// file may change from version to version without notice, or even be removed.
|
||||||
|
//
|
||||||
|
// We mean it.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef QTTOOLBARDIALOG_H
|
||||||
|
#define QTTOOLBARDIALOG_H
|
||||||
|
|
||||||
|
#include <QtGui/QDialog>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QMainWindow;
|
||||||
|
class QAction;
|
||||||
|
class QToolBar;
|
||||||
|
|
||||||
|
class QtToolBarManagerPrivate;
|
||||||
|
|
||||||
|
class QtToolBarManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit QtToolBarManager(QObject *parent = 0);
|
||||||
|
~QtToolBarManager();
|
||||||
|
|
||||||
|
void setMainWindow(QMainWindow *mainWindow);
|
||||||
|
QMainWindow *mainWindow() const;
|
||||||
|
|
||||||
|
void addAction(QAction *action, const QString &category);
|
||||||
|
void removeAction(QAction *action);
|
||||||
|
|
||||||
|
void addToolBar(QToolBar *toolBar, const QString &category);
|
||||||
|
void removeToolBar(QToolBar *toolBar);
|
||||||
|
|
||||||
|
QList<QToolBar *> toolBars() const;
|
||||||
|
|
||||||
|
QByteArray saveState(int version = 0) const;
|
||||||
|
bool restoreState(const QByteArray &state, int version = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend class QtToolBarDialog;
|
||||||
|
QScopedPointer<QtToolBarManagerPrivate> d_ptr;
|
||||||
|
Q_DECLARE_PRIVATE(QtToolBarManager)
|
||||||
|
Q_DISABLE_COPY(QtToolBarManager)
|
||||||
|
};
|
||||||
|
|
||||||
|
class QtToolBarDialogPrivate;
|
||||||
|
|
||||||
|
class QtToolBarDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit QtToolBarDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||||
|
~QtToolBarDialog();
|
||||||
|
|
||||||
|
void setToolBarManager(QtToolBarManager *toolBarManager);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void showEvent(QShowEvent *event);
|
||||||
|
void hideEvent(QHideEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QScopedPointer<QtToolBarDialogPrivate> d_ptr;
|
||||||
|
Q_DECLARE_PRIVATE(QtToolBarDialog)
|
||||||
|
Q_DISABLE_COPY(QtToolBarDialog)
|
||||||
|
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void newClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void removeClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void defaultClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void okClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void applyClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void cancelClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void upClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void downClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void leftClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void rightClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void renameClicked())
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void toolBarRenamed(QListWidgetItem *))
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void currentActionChanged(QTreeWidgetItem *))
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void currentToolBarChanged(QListWidgetItem *))
|
||||||
|
Q_PRIVATE_SLOT(d_func(), void currentToolBarActionChanged(QListWidgetItem *))
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,207 @@
|
||||||
|
<ui version="4.0" >
|
||||||
|
<class>QtToolBarDialog</class>
|
||||||
|
<widget class="QDialog" name="QtToolBarDialog" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>583</width>
|
||||||
|
<height>508</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>Customize Toolbars</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item rowspan="3" row="1" column="0" >
|
||||||
|
<widget class="QTreeWidget" name="actionTree" >
|
||||||
|
<column>
|
||||||
|
<property name="text" >
|
||||||
|
<string>1</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Actions</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="2" >
|
||||||
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Toolbars</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="newButton" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Add new toolbar</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>New</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="removeButton" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Remove selected toolbar</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="renameButton" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Rename toolbar</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Rename</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1" >
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="upButton" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Move action up</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Up</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="leftButton" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Remove action from toolbar</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string><-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="rightButton" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Add action to toolbar</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>-></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="downButton" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Move action down</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Down</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0" >
|
||||||
|
<size>
|
||||||
|
<width>29</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2" >
|
||||||
|
<widget class="QListWidget" name="currentToolBarList" />
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2" >
|
||||||
|
<widget class="QLabel" name="label_3" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Current Toolbar Actions</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2" >
|
||||||
|
<widget class="QListWidget" name="toolBarList" />
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="3" >
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||||
|
<property name="standardButtons" >
|
||||||
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>newButton</tabstop>
|
||||||
|
<tabstop>removeButton</tabstop>
|
||||||
|
<tabstop>renameButton</tabstop>
|
||||||
|
<tabstop>toolBarList</tabstop>
|
||||||
|
<tabstop>upButton</tabstop>
|
||||||
|
<tabstop>leftButton</tabstop>
|
||||||
|
<tabstop>rightButton</tabstop>
|
||||||
|
<tabstop>downButton</tabstop>
|
||||||
|
<tabstop>currentToolBarList</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -0,0 +1,173 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "saveformastemplate.h"
|
||||||
|
#include "qdesigner_settings.h"
|
||||||
|
|
||||||
|
#include <QtCore/QFile>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
|
||||||
|
#include <QtDesigner/abstractformeditor.h>
|
||||||
|
#include <QtDesigner/abstractformwindow.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
SaveFormAsTemplate::SaveFormAsTemplate(QDesignerFormEditorInterface *core,
|
||||||
|
QDesignerFormWindowInterface *formWindow,
|
||||||
|
QWidget *parent)
|
||||||
|
: QDialog(parent, Qt::Sheet),
|
||||||
|
m_core(core),
|
||||||
|
m_formWindow(formWindow)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
|
||||||
|
ui.templateNameEdit->setText(formWindow->mainContainer()->objectName());
|
||||||
|
ui.templateNameEdit->selectAll();
|
||||||
|
|
||||||
|
ui.templateNameEdit->setFocus();
|
||||||
|
|
||||||
|
QStringList paths = QDesignerSettings(m_core).formTemplatePaths();
|
||||||
|
ui.categoryCombo->addItems(paths);
|
||||||
|
ui.categoryCombo->addItem(tr("Add path..."));
|
||||||
|
m_addPathIndex = ui.categoryCombo->count() - 1;
|
||||||
|
connect(ui.templateNameEdit, SIGNAL(textChanged(QString)),
|
||||||
|
this, SLOT(updateOKButton(QString)));
|
||||||
|
connect(ui.categoryCombo, SIGNAL(activated(int)), this, SLOT(checkToAddPath(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveFormAsTemplate::~SaveFormAsTemplate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveFormAsTemplate::accept()
|
||||||
|
{
|
||||||
|
QString templateFileName = ui.categoryCombo->currentText();
|
||||||
|
templateFileName += QLatin1Char('/');
|
||||||
|
const QString name = ui.templateNameEdit->text();
|
||||||
|
templateFileName += name;
|
||||||
|
const QString extension = QLatin1String(".ui");
|
||||||
|
if (!templateFileName.endsWith(extension))
|
||||||
|
templateFileName.append(extension);
|
||||||
|
QFile file(templateFileName);
|
||||||
|
|
||||||
|
if (file.exists()) {
|
||||||
|
QMessageBox msgBox(QMessageBox::Information, tr("Template Exists"),
|
||||||
|
tr("A template with the name %1 already exists.\n"
|
||||||
|
"Do you want overwrite the template?").arg(name), QMessageBox::Cancel, m_formWindow);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||||
|
QPushButton *overwriteButton = msgBox.addButton(tr("Overwrite Template"), QMessageBox::AcceptRole);
|
||||||
|
msgBox.exec();
|
||||||
|
if (msgBox.clickedButton() != overwriteButton)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!file.open(QFile::WriteOnly)) {
|
||||||
|
if (QMessageBox::information(m_formWindow, tr("Open Error"),
|
||||||
|
tr("There was an error opening template %1 for writing. Reason: %2").arg(name).arg(file.errorString()),
|
||||||
|
QMessageBox::Retry|QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString origName = m_formWindow->fileName();
|
||||||
|
// ensure m_formWindow->contents() will convert properly resource paths to relative paths
|
||||||
|
// (relative to template location, not to the current form location)
|
||||||
|
m_formWindow->setFileName(templateFileName);
|
||||||
|
QByteArray ba = m_formWindow->contents().toUtf8();
|
||||||
|
m_formWindow->setFileName(origName);
|
||||||
|
while (file.write(ba) != ba.size()) {
|
||||||
|
if (QMessageBox::information(m_formWindow, tr("Write Error"),
|
||||||
|
tr("There was an error writing the template %1 to disk. Reason: %2").arg(name).arg(file.errorString()),
|
||||||
|
QMessageBox::Retry|QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel) {
|
||||||
|
file.close();
|
||||||
|
file.remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
file.reset();
|
||||||
|
}
|
||||||
|
// update the list of places too...
|
||||||
|
QStringList sl;
|
||||||
|
for (int i = 0; i < m_addPathIndex; ++i)
|
||||||
|
sl << ui.categoryCombo->itemText(i);
|
||||||
|
|
||||||
|
QDesignerSettings(m_core).setFormTemplatePaths(sl);
|
||||||
|
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveFormAsTemplate::updateOKButton(const QString &str)
|
||||||
|
{
|
||||||
|
QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
okButton->setEnabled(!str.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SaveFormAsTemplate::chooseTemplatePath(QWidget *parent)
|
||||||
|
{
|
||||||
|
QString rc = QFileDialog::getExistingDirectory(parent,
|
||||||
|
tr("Pick a directory to save templates in"));
|
||||||
|
if (rc.isEmpty())
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if (rc.endsWith(QDir::separator()))
|
||||||
|
rc.remove(rc.size() - 1, 1);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveFormAsTemplate::checkToAddPath(int itemIndex)
|
||||||
|
{
|
||||||
|
if (itemIndex != m_addPathIndex)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString dir = chooseTemplatePath(this);
|
||||||
|
if (dir.isEmpty()) {
|
||||||
|
ui.categoryCombo->setCurrentIndex(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.categoryCombo->insertItem(m_addPathIndex, dir);
|
||||||
|
ui.categoryCombo->setCurrentIndex(m_addPathIndex);
|
||||||
|
++m_addPathIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,77 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 SAVEFORMASTEMPLATE_H
|
||||||
|
#define SAVEFORMASTEMPLATE_H
|
||||||
|
|
||||||
|
#include "ui_saveformastemplate.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QDesignerFormEditorInterface;
|
||||||
|
class QDesignerFormWindowInterface;
|
||||||
|
|
||||||
|
class SaveFormAsTemplate: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SaveFormAsTemplate(QDesignerFormEditorInterface *m_core,
|
||||||
|
QDesignerFormWindowInterface *formWindow,
|
||||||
|
QWidget *parent = 0);
|
||||||
|
virtual ~SaveFormAsTemplate();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void accept();
|
||||||
|
void updateOKButton(const QString &str);
|
||||||
|
void checkToAddPath(int itemIndex);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QString chooseTemplatePath(QWidget *parent);
|
||||||
|
|
||||||
|
Ui::SaveFormAsTemplate ui;
|
||||||
|
QDesignerFormEditorInterface *m_core;
|
||||||
|
QDesignerFormWindowInterface *m_formWindow;
|
||||||
|
int m_addPathIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // SAVEFORMASTEMPLATE_H
|
|
@ -0,0 +1,166 @@
|
||||||
|
<ui version="4.0" >
|
||||||
|
<comment>*********************************************************************
|
||||||
|
**
|
||||||
|
** 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$
|
||||||
|
**
|
||||||
|
*********************************************************************</comment>
|
||||||
|
<class>SaveFormAsTemplate</class>
|
||||||
|
<widget class="QDialog" name="SaveFormAsTemplate" >
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>Save Form As Template</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" >
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="frameShape" >
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow" >
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Name:</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat" >
|
||||||
|
<enum>Qt::AutoText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>templateNameEdit</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QLineEdit" name="templateNameEdit" >
|
||||||
|
<property name="minimumSize" >
|
||||||
|
<size>
|
||||||
|
<width>222</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="echoMode" >
|
||||||
|
<enum>QLineEdit::Normal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" >
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="frameShape" >
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow" >
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Category:</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat" >
|
||||||
|
<enum>Qt::AutoText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>categoryCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" >
|
||||||
|
<widget class="QComboBox" name="categoryCombo" />
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="horizontalLine" >
|
||||||
|
<property name="frameShape" >
|
||||||
|
<enum>QFrame::HLine</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow" >
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons" >
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>SaveFormAsTemplate</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel" >
|
||||||
|
<x>256</x>
|
||||||
|
<y>124</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel" >
|
||||||
|
<x>113</x>
|
||||||
|
<y>143</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>SaveFormAsTemplate</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel" >
|
||||||
|
<x>332</x>
|
||||||
|
<y>127</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel" >
|
||||||
|
<x>372</x>
|
||||||
|
<y>147</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -0,0 +1,191 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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/QVector>
|
||||||
|
#include <QtGui/QMouseEvent>
|
||||||
|
#include <QtGui/QGridLayout>
|
||||||
|
#include <QtGui/QLabel>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
#include <QtGui/QDialogButtonBox>
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
#include <QtGui/QPainterPath>
|
||||||
|
#include <QtGui/QStyleOption>
|
||||||
|
#include "versiondialog.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class VersionLabel : public QLabel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VersionLabel(QWidget *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void triggered();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *me);
|
||||||
|
void mouseMoveEvent(QMouseEvent *me);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *me);
|
||||||
|
void paintEvent(QPaintEvent *pe);
|
||||||
|
private:
|
||||||
|
QVector<QPoint> hitPoints;
|
||||||
|
QVector<QPoint> missPoints;
|
||||||
|
QPainterPath m_path;
|
||||||
|
bool secondStage;
|
||||||
|
bool m_pushed;
|
||||||
|
};
|
||||||
|
|
||||||
|
VersionLabel::VersionLabel(QWidget *parent)
|
||||||
|
: QLabel(parent), secondStage(false), m_pushed(false)
|
||||||
|
{
|
||||||
|
setPixmap(QPixmap(QLatin1String(":/trolltech/designer/images/designer.png")));
|
||||||
|
hitPoints.append(QPoint(56, 25));
|
||||||
|
hitPoints.append(QPoint(29, 55));
|
||||||
|
hitPoints.append(QPoint(56, 87));
|
||||||
|
hitPoints.append(QPoint(82, 55));
|
||||||
|
hitPoints.append(QPoint(58, 56));
|
||||||
|
|
||||||
|
secondStage = false;
|
||||||
|
m_pushed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VersionLabel::mousePressEvent(QMouseEvent *me)
|
||||||
|
{
|
||||||
|
if (me->button() == Qt::LeftButton) {
|
||||||
|
if (!secondStage) {
|
||||||
|
m_path = QPainterPath(me->pos());
|
||||||
|
} else {
|
||||||
|
m_pushed = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VersionLabel::mouseMoveEvent(QMouseEvent *me)
|
||||||
|
{
|
||||||
|
if (me->buttons() & Qt::LeftButton)
|
||||||
|
if (!secondStage)
|
||||||
|
m_path.lineTo(me->pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void VersionLabel::mouseReleaseEvent(QMouseEvent *me)
|
||||||
|
{
|
||||||
|
if (me->button() == Qt::LeftButton) {
|
||||||
|
if (!secondStage) {
|
||||||
|
m_path.lineTo(me->pos());
|
||||||
|
bool gotIt = true;
|
||||||
|
foreach(const QPoint &pt, hitPoints) {
|
||||||
|
if (!m_path.contains(pt)) {
|
||||||
|
gotIt = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gotIt) {
|
||||||
|
foreach(const QPoint &pt, missPoints) {
|
||||||
|
if (m_path.contains(pt)) {
|
||||||
|
gotIt = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gotIt && !secondStage) {
|
||||||
|
secondStage = true;
|
||||||
|
m_path = QPainterPath();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_pushed = false;
|
||||||
|
update();
|
||||||
|
emit triggered();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VersionLabel::paintEvent(QPaintEvent *pe)
|
||||||
|
{
|
||||||
|
if (secondStage) {
|
||||||
|
QPainter p(this);
|
||||||
|
QStyleOptionButton opt;
|
||||||
|
opt.init(this);
|
||||||
|
if (!m_pushed)
|
||||||
|
opt.state |= QStyle::State_Raised;
|
||||||
|
else
|
||||||
|
opt.state |= QStyle::State_Sunken;
|
||||||
|
opt.state &= ~QStyle::State_HasFocus;
|
||||||
|
style()->drawControl(QStyle::CE_PushButtonBevel, &opt, &p, this);
|
||||||
|
}
|
||||||
|
QLabel::paintEvent(pe);
|
||||||
|
}
|
||||||
|
|
||||||
|
VersionDialog::VersionDialog(QWidget *parent)
|
||||||
|
: QDialog(parent
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
, Qt::Tool
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
setWindowFlags((windowFlags() & ~Qt::WindowContextHelpButtonHint) | Qt::MSWindowsFixedSizeDialogHint);
|
||||||
|
QGridLayout *layout = new QGridLayout(this);
|
||||||
|
VersionLabel *label = new VersionLabel;
|
||||||
|
QLabel *lbl = new QLabel;
|
||||||
|
QString version = tr("<h3>%1</h3><br/><br/>Version %2");
|
||||||
|
version = version.arg(tr("Qt Designer")).arg(QLatin1String(QT_VERSION_STR));
|
||||||
|
version.append(tr("<br/>Qt Designer is a graphical user interface designer for Qt applications.<br/>"));
|
||||||
|
|
||||||
|
lbl->setText(tr("%1"
|
||||||
|
"<br/>Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)."
|
||||||
|
).arg(version));
|
||||||
|
|
||||||
|
lbl->setWordWrap(true);
|
||||||
|
lbl->setOpenExternalLinks(true);
|
||||||
|
|
||||||
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||||
|
connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
connect(label, SIGNAL(triggered()), this, SLOT(accept()));
|
||||||
|
layout->addWidget(label, 0, 0, 1, 1);
|
||||||
|
layout->addWidget(lbl, 0, 1, 4, 4);
|
||||||
|
layout->addWidget(buttonBox, 4, 2, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#include "versiondialog.moc"
|
|
@ -0,0 +1,58 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 VERSIONDIALOG_H
|
||||||
|
#define VERSIONDIALOG_H
|
||||||
|
|
||||||
|
#include <QtGui/QDialog>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class VersionDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit VersionDialog(QWidget *parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,178 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 <QtDesigner/default_extensionfactory.h>
|
||||||
|
#include "qextensionmanager.h"
|
||||||
|
#include <qpointer.h>
|
||||||
|
#include <QtCore/qdebug.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QExtensionFactory
|
||||||
|
|
||||||
|
\brief The QExtensionFactory class allows you to create a factory
|
||||||
|
that is able to make instances of custom extensions in Qt
|
||||||
|
Designer.
|
||||||
|
|
||||||
|
\inmodule QtDesigner
|
||||||
|
|
||||||
|
In \QD the extensions are not created until they are required. For
|
||||||
|
that reason, when implementing a custom extension, you must also
|
||||||
|
create a QExtensionFactory, i.e. a class that is able to make an
|
||||||
|
instance of your extension, and register it using \QD's \l
|
||||||
|
{QExtensionManager}{extension manager}.
|
||||||
|
|
||||||
|
The QExtensionManager class provides extension management
|
||||||
|
facilities for Qt Designer. When an extension is required, Qt
|
||||||
|
Designer's \l {QExtensionManager}{extension manager} will run
|
||||||
|
through all its registered factories calling
|
||||||
|
QExtensionFactory::createExtension() for each until the first one
|
||||||
|
that is able to create a requested extension for the selected
|
||||||
|
object, is found. This factory will then make an instance of the
|
||||||
|
extension.
|
||||||
|
|
||||||
|
There are four available types of extensions in Qt Designer:
|
||||||
|
QDesignerContainerExtension , QDesignerMemberSheetExtension,
|
||||||
|
QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt
|
||||||
|
Designer's behavior is the same whether the requested extension is
|
||||||
|
associated with a multi page container, a member sheet, a property
|
||||||
|
sheet or a task menu.
|
||||||
|
|
||||||
|
You can either create a new QExtensionFactory and reimplement the
|
||||||
|
QExtensionFactory::createExtension() function. For example:
|
||||||
|
|
||||||
|
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp 0
|
||||||
|
|
||||||
|
Or you can use an existing factory, expanding the
|
||||||
|
QExtensionFactory::createExtension() function to make the factory
|
||||||
|
able to create your extension as well. For example:
|
||||||
|
|
||||||
|
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp 1
|
||||||
|
|
||||||
|
For a complete example using the QExtensionFactory class, see the
|
||||||
|
\l {designer/taskmenuextension}{Task Menu Extension example}. The
|
||||||
|
example shows how to create a custom widget plugin for Qt
|
||||||
|
Designer, and how to to use the QDesignerTaskMenuExtension class
|
||||||
|
to add custom items to Qt Designer's task menu.
|
||||||
|
|
||||||
|
\sa QExtensionManager, QAbstractExtensionFactory
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs an extension factory with the given \a parent.
|
||||||
|
*/
|
||||||
|
QExtensionFactory::QExtensionFactory(QExtensionManager *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the extension specified by \a iid for the given \a object.
|
||||||
|
|
||||||
|
\sa createExtension()
|
||||||
|
*/
|
||||||
|
|
||||||
|
QObject *QExtensionFactory::extension(QObject *object, const QString &iid) const
|
||||||
|
{
|
||||||
|
if (!object)
|
||||||
|
return 0;
|
||||||
|
const IdObjectKey key = qMakePair(iid, object);
|
||||||
|
|
||||||
|
ExtensionMap::iterator it = m_extensions.find(key);
|
||||||
|
if (it == m_extensions.end()) {
|
||||||
|
if (QObject *ext = createExtension(object, iid, const_cast<QExtensionFactory*>(this))) {
|
||||||
|
connect(ext, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
|
||||||
|
it = m_extensions.insert(key, ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_extended.contains(object)) {
|
||||||
|
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
|
||||||
|
m_extended.insert(object, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it == m_extensions.end())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return it.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExtensionFactory::objectDestroyed(QObject *object)
|
||||||
|
{
|
||||||
|
QMutableMapIterator< IdObjectKey, QObject*> it(m_extensions);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
|
||||||
|
QObject *o = it.key().second;
|
||||||
|
if (o == object || object == it.value()) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_extended.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Creates an extension specified by \a iid for the given \a object.
|
||||||
|
The extension object is created as a child of the specified \a
|
||||||
|
parent.
|
||||||
|
|
||||||
|
\sa extension()
|
||||||
|
*/
|
||||||
|
QObject *QExtensionFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(object);
|
||||||
|
Q_UNUSED(iid);
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the extension manager for the extension factory.
|
||||||
|
*/
|
||||||
|
QExtensionManager *QExtensionFactory::extensionManager() const
|
||||||
|
{
|
||||||
|
return static_cast<QExtensionManager *>(parent());
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,86 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 DEFAULT_EXTENSIONFACTORY_H
|
||||||
|
#define DEFAULT_EXTENSIONFACTORY_H
|
||||||
|
|
||||||
|
#include <QtDesigner/extension_global.h>
|
||||||
|
#include <QtDesigner/extension.h>
|
||||||
|
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
#include <QtCore/QPair>
|
||||||
|
|
||||||
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QExtensionManager;
|
||||||
|
|
||||||
|
class QDESIGNER_EXTENSION_EXPORT QExtensionFactory : public QObject, public QAbstractExtensionFactory
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(QAbstractExtensionFactory)
|
||||||
|
public:
|
||||||
|
QExtensionFactory(QExtensionManager *parent = 0);
|
||||||
|
|
||||||
|
virtual QObject *extension(QObject *object, const QString &iid) const;
|
||||||
|
QExtensionManager *extensionManager() const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void objectDestroyed(QObject *object);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef QPair<QString,QObject*> IdObjectKey;
|
||||||
|
typedef QMap< IdObjectKey, QObject*> ExtensionMap;
|
||||||
|
mutable ExtensionMap m_extensions;
|
||||||
|
typedef QHash<QObject*, bool> ExtendedSet;
|
||||||
|
mutable ExtendedSet m_extended;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
QT_END_HEADER
|
||||||
|
|
||||||
|
#endif // DEFAULT_EXTENSIONFACTORY_H
|
|
@ -0,0 +1,186 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 <QtDesigner/extension.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QAbstractExtensionFactory
|
||||||
|
|
||||||
|
\brief The QAbstractExtensionFactory class provides an interface
|
||||||
|
for extension factories in Qt Designer.
|
||||||
|
|
||||||
|
\inmodule QtDesigner
|
||||||
|
|
||||||
|
QAbstractExtensionFactory is not intended to be instantiated
|
||||||
|
directly; use the QExtensionFactory instead.
|
||||||
|
|
||||||
|
In \QD, extension factories are used to look up and create named
|
||||||
|
extensions as they are required. For that reason, when
|
||||||
|
implementing a custom extension, you must also create a
|
||||||
|
QExtensionFactory, i.e a class that is able to make an instance of
|
||||||
|
your extension, and register it using \QD's \l
|
||||||
|
{QExtensionManager}{extension manager}.
|
||||||
|
|
||||||
|
When an extension is required, \QD's \l
|
||||||
|
{QExtensionManager}{extension manager} will run through all its
|
||||||
|
registered factories calling QExtensionFactory::createExtension()
|
||||||
|
for each until the first one that is able to create the requested
|
||||||
|
extension for the selected object, is found. This factory will
|
||||||
|
then make an instance of the extension.
|
||||||
|
|
||||||
|
\sa QExtensionFactory, QExtensionManager
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QAbstractExtensionFactory::~QAbstractExtensionFactory()
|
||||||
|
|
||||||
|
Destroys the extension factory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QObject *QAbstractExtensionFactory::extension(QObject *object, const QString &iid) const
|
||||||
|
|
||||||
|
Returns the extension specified by \a iid for the given \a object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QAbstractExtensionManager
|
||||||
|
|
||||||
|
\brief The QAbstractExtensionManager class provides an interface
|
||||||
|
for extension managers in Qt Designer.
|
||||||
|
|
||||||
|
\inmodule QtDesigner
|
||||||
|
|
||||||
|
QAbstractExtensionManager is not intended to be instantiated
|
||||||
|
directly; use the QExtensionManager instead.
|
||||||
|
|
||||||
|
In \QD, extension are not created until they are required. For
|
||||||
|
that reason, when implementing a custom extension, you must also
|
||||||
|
create a QExtensionFactory, i.e a class that is able to make an
|
||||||
|
instance of your extension, and register it using \QD's \l
|
||||||
|
{QExtensionManager}{extension manager}.
|
||||||
|
|
||||||
|
When an extension is required, \QD's \l
|
||||||
|
{QExtensionManager}{extension manager} will run through all its
|
||||||
|
registered factories calling QExtensionFactory::createExtension()
|
||||||
|
for each until the first one that is able to create the requested
|
||||||
|
extension for the selected object, is found. This factory will
|
||||||
|
then make an instance of the extension.
|
||||||
|
|
||||||
|
\sa QExtensionManager, QExtensionFactory
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QAbstractExtensionManager::~QAbstractExtensionManager()
|
||||||
|
|
||||||
|
Destroys the extension manager.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QAbstractExtensionManager::registerExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||||
|
|
||||||
|
Register the given extension \a factory with the extension
|
||||||
|
specified by \a iid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QAbstractExtensionManager::unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||||
|
|
||||||
|
Unregister the given \a factory with the extension specified by \a
|
||||||
|
iid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QObject *QAbstractExtensionManager::extension(QObject *object, const QString &iid) const
|
||||||
|
|
||||||
|
Returns the extension, specified by \a iid, for the given \a
|
||||||
|
object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn T qt_extension(QAbstractExtensionManager* manager, QObject *object)
|
||||||
|
|
||||||
|
\relates QExtensionManager
|
||||||
|
|
||||||
|
Returns the extension of the given \a object cast to type T if the
|
||||||
|
object is of type T (or of a subclass); otherwise returns 0. The
|
||||||
|
extension is retrieved using the given extension \a manager.
|
||||||
|
|
||||||
|
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp 0
|
||||||
|
|
||||||
|
When implementing a custom widget plugin, a pointer to \QD's
|
||||||
|
current QDesignerFormEditorInterface object (\c formEditor) is
|
||||||
|
provided by the QDesignerCustomWidgetInterface::initialize()
|
||||||
|
function's parameter.
|
||||||
|
|
||||||
|
If the widget in the example above doesn't have a defined
|
||||||
|
QDesignerPropertySheetExtension, \c propertySheet will be a null
|
||||||
|
pointer.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\macro Q_DECLARE_EXTENSION_INTERFACE(ExtensionName, Identifier)
|
||||||
|
|
||||||
|
\relates QExtensionManager
|
||||||
|
|
||||||
|
Associates the given \a Identifier (a string literal) to the
|
||||||
|
extension class called \a ExtensionName. The \a Identifier must be
|
||||||
|
unique. For example:
|
||||||
|
|
||||||
|
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp 1
|
||||||
|
|
||||||
|
Using the company and product names is a good way to ensure
|
||||||
|
uniqueness of the identifier.
|
||||||
|
|
||||||
|
When implementing a custom extension class, you must use
|
||||||
|
Q_DECLARE_EXTENSION_INTERFACE() to enable usage of the
|
||||||
|
qt_extension() function. The macro is normally located right after the
|
||||||
|
class definition for \a ExtensionName, in the associated header
|
||||||
|
file.
|
||||||
|
|
||||||
|
\sa Q_DECLARE_INTERFACE()
|
||||||
|
*/
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,109 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 EXTENSION_H
|
||||||
|
#define EXTENSION_H
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#define Q_TYPEID(IFace) QLatin1String(IFace##_iid)
|
||||||
|
|
||||||
|
class QAbstractExtensionFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~QAbstractExtensionFactory() {}
|
||||||
|
|
||||||
|
virtual QObject *extension(QObject *object, const QString &iid) const = 0;
|
||||||
|
};
|
||||||
|
Q_DECLARE_INTERFACE(QAbstractExtensionFactory, "com.trolltech.Qt.QAbstractExtensionFactory")
|
||||||
|
|
||||||
|
class QAbstractExtensionManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~QAbstractExtensionManager() {}
|
||||||
|
|
||||||
|
virtual void registerExtensions(QAbstractExtensionFactory *factory, const QString &iid) = 0;
|
||||||
|
virtual void unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid) = 0;
|
||||||
|
|
||||||
|
virtual QObject *extension(QObject *object, const QString &iid) const = 0;
|
||||||
|
};
|
||||||
|
Q_DECLARE_INTERFACE(QAbstractExtensionManager, "com.trolltech.Qt.QAbstractExtensionManager")
|
||||||
|
|
||||||
|
#if defined(Q_CC_MSVC) && (_MSC_VER < 1300)
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T qt_extension_helper(QAbstractExtensionManager *, QObject *, T)
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T qt_extension(QAbstractExtensionManager* manager, QObject *object)
|
||||||
|
{ return qt_extension_helper(manager, object, T(0)); }
|
||||||
|
|
||||||
|
#define Q_DECLARE_EXTENSION_INTERFACE(IFace, IId) \
|
||||||
|
const char * const IFace##_iid = IId; \
|
||||||
|
Q_DECLARE_INTERFACE(IFace, IId) \
|
||||||
|
template <> inline IFace *qt_extension_helper<IFace *>(QAbstractExtensionManager *manager, QObject *object, IFace *) \
|
||||||
|
{ QObject *extension = manager->extension(object, Q_TYPEID(IFace)); return (IFace *)(extension ? extension->qt_metacast(IFace##_iid) : 0); }
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T qt_extension(QAbstractExtensionManager* manager, QObject *object)
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
|
#define Q_DECLARE_EXTENSION_INTERFACE(IFace, IId) \
|
||||||
|
const char * const IFace##_iid = IId; \
|
||||||
|
Q_DECLARE_INTERFACE(IFace, IId) \
|
||||||
|
template <> inline IFace *qt_extension<IFace *>(QAbstractExtensionManager *manager, QObject *object) \
|
||||||
|
{ QObject *extension = manager->extension(object, Q_TYPEID(IFace)); return extension ? static_cast<IFace *>(extension->qt_metacast(IFace##_iid)) : static_cast<IFace *>(0); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
QT_END_HEADER
|
||||||
|
|
||||||
|
#endif // EXTENSION_H
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Input
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
HEADERS += $$PWD/default_extensionfactory.h \
|
||||||
|
$$PWD/extension.h \
|
||||||
|
$$PWD/qextensionmanager.h
|
||||||
|
|
||||||
|
SOURCES += $$PWD/default_extensionfactory.cpp \
|
||||||
|
$$PWD/extension.cpp \
|
||||||
|
$$PWD/qextensionmanager.cpp
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 EXTENSION_GLOBAL_H
|
||||||
|
#define EXTENSION_GLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
QT_BEGIN_HEADER
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#define QDESIGNER_EXTENSION_EXTERN Q_DECL_EXPORT
|
||||||
|
#define QDESIGNER_EXTENSION_IMPORT Q_DECL_IMPORT
|
||||||
|
|
||||||
|
#ifdef QT_DESIGNER_STATIC
|
||||||
|
# define QDESIGNER_EXTENSION_EXPORT
|
||||||
|
#elif defined(QDESIGNER_EXTENSION_LIBRARY)
|
||||||
|
# define QDESIGNER_EXTENSION_EXPORT QDESIGNER_EXTENSION_EXTERN
|
||||||
|
#else
|
||||||
|
# define QDESIGNER_EXTENSION_EXPORT QDESIGNER_EXTENSION_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
QT_END_HEADER
|
||||||
|
|
||||||
|
#endif // EXTENSION_GLOBAL_H
|
|
@ -0,0 +1,174 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "qextensionmanager.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class QExtensionManager
|
||||||
|
|
||||||
|
\brief The QExtensionManager class provides extension management
|
||||||
|
facilities for Qt Designer.
|
||||||
|
|
||||||
|
\inmodule QtDesigner
|
||||||
|
|
||||||
|
In \QD the extensions are not created until they are required. For
|
||||||
|
that reason, when implementing an extension, you must also create
|
||||||
|
a QExtensionFactory, i.e a class that is able to make an instance
|
||||||
|
of your extension, and register it using \QD's extension manager.
|
||||||
|
|
||||||
|
The registration of an extension factory is typically made in the
|
||||||
|
QDesignerCustomWidgetInterface::initialize() function:
|
||||||
|
|
||||||
|
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp 0
|
||||||
|
|
||||||
|
The QExtensionManager is not intended to be instantiated
|
||||||
|
directly. You can retrieve an interface to \QD's extension manager
|
||||||
|
using the QDesignerFormEditorInterface::extensionManager()
|
||||||
|
function. A pointer to \QD's current QDesignerFormEditorInterface
|
||||||
|
object (\c formEditor in the example above) is provided by the
|
||||||
|
QDesignerCustomWidgetInterface::initialize() function's
|
||||||
|
parameter. When implementing a custom widget plugin, you must
|
||||||
|
subclass the QDesignerCustomWidgetInterface to expose your plugin
|
||||||
|
to \QD.
|
||||||
|
|
||||||
|
Then, when an extension is required, \QD's extension manager will
|
||||||
|
run through all its registered factories calling
|
||||||
|
QExtensionFactory::createExtension() for each until the first one
|
||||||
|
that is able to create the requested extension for the selected
|
||||||
|
object, is found. This factory will then make an instance of the
|
||||||
|
extension.
|
||||||
|
|
||||||
|
There are four available types of extensions in \QD:
|
||||||
|
QDesignerContainerExtension , QDesignerMemberSheetExtension,
|
||||||
|
QDesignerPropertySheetExtension and
|
||||||
|
QDesignerTaskMenuExtension. \QD's behavior is the same whether the
|
||||||
|
requested extension is associated with a container, a member
|
||||||
|
sheet, a property sheet or a task menu.
|
||||||
|
|
||||||
|
For a complete example using the QExtensionManager class, see the
|
||||||
|
\l {designer/taskmenuextension}{Task Menu Extension example}. The
|
||||||
|
example shows how to create a custom widget plugin for Qt
|
||||||
|
Designer, and how to to use the QDesignerTaskMenuExtension class
|
||||||
|
to add custom items to \QD's task menu.
|
||||||
|
|
||||||
|
\sa QExtensionFactory, QAbstractExtensionManager
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs an extension manager with the given \a parent.
|
||||||
|
*/
|
||||||
|
QExtensionManager::QExtensionManager(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Destroys the extension manager
|
||||||
|
*/
|
||||||
|
QExtensionManager::~QExtensionManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Register the extension specified by the given \a factory and
|
||||||
|
extension identifier \a iid.
|
||||||
|
*/
|
||||||
|
void QExtensionManager::registerExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||||
|
{
|
||||||
|
if (iid.isEmpty()) {
|
||||||
|
m_globalExtension.prepend(factory);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FactoryMap::iterator it = m_extensions.find(iid);
|
||||||
|
if (it == m_extensions.end())
|
||||||
|
it = m_extensions.insert(iid, FactoryList());
|
||||||
|
|
||||||
|
it.value().prepend(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Unregister the extension specified by the given \a factory and
|
||||||
|
extension identifier \a iid.
|
||||||
|
*/
|
||||||
|
void QExtensionManager::unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||||
|
{
|
||||||
|
if (iid.isEmpty()) {
|
||||||
|
m_globalExtension.removeAll(factory);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FactoryMap::iterator it = m_extensions.find(iid);
|
||||||
|
if (it == m_extensions.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
FactoryList &factories = it.value();
|
||||||
|
factories.removeAll(factory);
|
||||||
|
|
||||||
|
if (factories.isEmpty())
|
||||||
|
m_extensions.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the extension specified by \a iid, for the given \a
|
||||||
|
object.
|
||||||
|
*/
|
||||||
|
QObject *QExtensionManager::extension(QObject *object, const QString &iid) const
|
||||||
|
{
|
||||||
|
const FactoryMap::const_iterator it = m_extensions.constFind(iid);
|
||||||
|
if (it != m_extensions.constEnd()) {
|
||||||
|
const FactoryList::const_iterator fcend = it.value().constEnd();
|
||||||
|
for (FactoryList::const_iterator fit = it.value().constBegin(); fit != fcend; ++fit)
|
||||||
|
if (QObject *ext = (*fit)->extension(object, iid))
|
||||||
|
return ext;
|
||||||
|
}
|
||||||
|
const FactoryList::const_iterator gfcend = m_globalExtension.constEnd();
|
||||||
|
for (FactoryList::const_iterator git = m_globalExtension.constBegin(); git != gfcend; ++git)
|
||||||
|
if (QObject *ext = (*git)->extension(object, iid))
|
||||||
|
return ext;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
|
@ -0,0 +1,79 @@
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 QEXTENSIONMANAGER_H
|
||||||
|
#define QEXTENSIONMANAGER_H
|
||||||
|
|
||||||
|
#include <QtDesigner/extension_global.h>
|
||||||
|
#include <QtDesigner/extension.h>
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
|
||||||
|
QT_BEGIN_HEADER
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QObject; // Fool syncqt
|
||||||
|
|
||||||
|
class QDESIGNER_EXTENSION_EXPORT QExtensionManager: public QObject, public QAbstractExtensionManager
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(QAbstractExtensionManager)
|
||||||
|
public:
|
||||||
|
QExtensionManager(QObject *parent = 0);
|
||||||
|
~QExtensionManager();
|
||||||
|
|
||||||
|
virtual void registerExtensions(QAbstractExtensionFactory *factory, const QString &iid = QString());
|
||||||
|
virtual void unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid = QString());
|
||||||
|
|
||||||
|
virtual QObject *extension(QObject *object, const QString &iid) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef QList<QAbstractExtensionFactory*> FactoryList;
|
||||||
|
typedef QHash<QString, FactoryList> FactoryMap;
|
||||||
|
FactoryMap m_extensions;
|
||||||
|
FactoryList m_globalExtension;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
QT_END_HEADER
|
||||||
|
|
||||||
|
#endif // QEXTENSIONMANAGER_H
|