summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-24 16:04:49 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-24 16:04:49 +0100
commit7fa9edc5e7a32c3e728013a6b16651742f049f46 (patch)
treea17b5e4afe53ad0e7b6eb1a7e8aea154d3d95182
parent97d4e5d6d0ce6d48b525648d5418c0debb459690 (diff)
parentd069c8d5a27fbae2c4020cb06633b518a783b5c4 (diff)
Merge remote-tracking branch 'origin/stable' into dev
-rw-r--r--examples/activeqt/comapp/doc/src/comapp.qdoc2
-rw-r--r--examples/activeqt/webbrowser/doc/src/webbrowser.qdoc4
-rw-r--r--examples/activeqt/webbrowser/main.cpp163
-rw-r--r--examples/activeqt/webbrowser/mainwindow.ui30
-rw-r--r--examples/activeqt/webbrowser/mainwindow_windowsmobile.ui30
-rw-r--r--src/activeqt/container/qaxbase.cpp10
-rw-r--r--src/activeqt/doc/src/activeqt-dumpcpp.qdoc2
-rw-r--r--src/activeqt/doc/src/qtaxcontainer.qdoc2
-rw-r--r--src/activeqt/doc/src/qtaxserver.qdoc6
9 files changed, 232 insertions, 17 deletions
diff --git a/examples/activeqt/comapp/doc/src/comapp.qdoc b/examples/activeqt/comapp/doc/src/comapp.qdoc
index 9addb30..69b27b6 100644
--- a/examples/activeqt/comapp/doc/src/comapp.qdoc
+++ b/examples/activeqt/comapp/doc/src/comapp.qdoc
@@ -79,7 +79,7 @@
\snippet activeqt/comapp/main.cpp 6
The classes are exported from the server using the QAxFactory macros. Only
\c Application objects can be instantiated from outside - the other APIs can
- only be used after accessing the respective objects throught the \c Application
+ only be used after accessing the respective objects throughout the \c Application
API.
\snippet activeqt/comapp/main.cpp 7
diff --git a/examples/activeqt/webbrowser/doc/src/webbrowser.qdoc b/examples/activeqt/webbrowser/doc/src/webbrowser.qdoc
index be1ff34..07c2ef7 100644
--- a/examples/activeqt/webbrowser/doc/src/webbrowser.qdoc
+++ b/examples/activeqt/webbrowser/doc/src/webbrowser.qdoc
@@ -51,9 +51,7 @@
\snippet activeqt/webbrowser/main.cpp 1
The constructor initializes the user interface, installs a
- progress bar on the status bar, and uses QAxBase::dynamicCall()
- to invoke the \c GoHome() method of Internet Explorer to
- navigate to the user's home page.
+ progress bar on the status bar, and loads the bookmarks.
\snippet activeqt/webbrowser/main.cpp 2
Different slots handle the signals emitted by the WebBrowser object.
diff --git a/examples/activeqt/webbrowser/main.cpp b/examples/activeqt/webbrowser/main.cpp
index e65526d..76470bc 100644
--- a/examples/activeqt/webbrowser/main.cpp
+++ b/examples/activeqt/webbrowser/main.cpp
@@ -46,6 +46,9 @@
#include <QStatusBar>
#include <QMainWindow>
#include <QAbstractEventDispatcher>
+#include <QSignalMapper>
+#include <QVariant>
+#include <QSettings>
#if defined(Q_WS_WINCE_WM)
#include "ui_mainwindow_windowsmobile.h"
@@ -54,29 +57,107 @@
#include "ui_mainwindow.h"
#endif
+static const char qtProjectUrl[] = "qt-project.org";
+static const char iWebBrowser2DocumentationUrl[] = "http://msdn.microsoft.com/en-us/library/aa752127%28v=vs.85%29.aspx";
+
+struct Location {
+ Location(const QString &t = QString(), const QString &a = QString()) : title(t), address(a) {}
+
+ QString title;
+ QString address;
+};
+
+Q_DECLARE_METATYPE(Location)
+
+static QList<Location> defaultBookmarks()
+{
+ QList<Location> result;
+ result.append(Location(QStringLiteral("Qt Project"), QLatin1String(qtProjectUrl)));
+ result.append(Location(QStringLiteral("Digia"), QStringLiteral("http://qt.digia.com/")));
+ result.append(Location(QStringLiteral("IWebBrowser2 MSDN Documentation"), QLatin1String(iWebBrowser2DocumentationUrl)));
+ return result;
+}
+
+static bool containsAddress(const QList<Location> &locations, const QString &address)
+{
+ foreach (const Location &location, locations) {
+ if (location.address == address)
+ return true;
+ }
+ return false;
+}
+
+static inline Location locationFromAction(const QAction *action)
+{
+ return action->data().value<Location>();
+}
+
+static QList<Location> readBookMarks(QSettings &settings)
+{
+ QList<Location> result;
+ if (const int count = settings.beginReadArray(QStringLiteral("Bookmarks"))) {
+ const QString titleKey = QStringLiteral("title");
+ const QString addressKey = QStringLiteral("address");
+ for (int i = 0; i < count; ++i) {
+ settings.setArrayIndex(i);
+ result.append(Location(settings.value(titleKey).toString(),
+ settings.value(addressKey).toString()));
+ }
+ }
+ settings.endArray();
+ return result;
+}
+
+static void saveBookMarks(const QList<Location> &bookmarks, QSettings &settings)
+{
+ const int count = bookmarks.size();
+ settings.beginWriteArray(QStringLiteral("Bookmarks"));
+ const QString titleKey = QStringLiteral("title");
+ const QString addressKey = QStringLiteral("address");
+ for (int i = 0; i < count; ++i) {
+ settings.setArrayIndex(i);
+ settings.setValue(titleKey, bookmarks.at(i).title);
+ settings.setValue(addressKey, bookmarks.at(i).address);
+ }
+ settings.endArray();
+}
+
//! [0]
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindow();
+ ~MainWindow();
public slots:
+ void navigate(const QString &address);
void on_WebBrowser_TitleChange(const QString &title);
void on_WebBrowser_ProgressChange(int a, int b);
void on_WebBrowser_CommandStateChange(int cmd, bool on);
void on_WebBrowser_BeforeNavigate();
- void on_WebBrowser_NavigateComplete(QString);
+ void on_WebBrowser_NavigateComplete(const QString &address);
void on_actionGo_triggered();
void on_actionNewWindow_triggered();
+ void on_actionAddBookmark_triggered();
void on_actionAbout_triggered();
void on_actionAboutQt_triggered();
void on_actionFileClose_triggered();
private:
+ inline const QString address() const
+ { return addressEdit->text().trimmed(); }
+ QList<Location> bookmarks() const;
+ QAction *addLocation(const Location &location, QMenu *menu);
+ inline void addBookmark(const Location &location)
+ { bookmarkActions << addLocation(location, BookmarksMenu); }
+
QProgressBar *pb;
QLineEdit *addressEdit;
+ QList<QAction *> bookmarkActions;
+ QList<QAction *> historyActions;
+ QSignalMapper locationActionMapper;
};
//! [0] //! [1]
@@ -101,13 +182,66 @@ MainWindow::MainWindow()
pb->hide();
statusBar()->addPermanentWidget(pb);
- WebBrowser->dynamicCall("GoHome()");
+ connect(&locationActionMapper, SIGNAL(mapped(QString)), this, SLOT(navigate(QString)));
+
+ QSettings settings(QSettings::IniFormat, QSettings::UserScope,
+ QCoreApplication::organizationName(), QCoreApplication::applicationName());
+ QList<Location> bookmarks = readBookMarks(settings);
+ if (bookmarks.isEmpty())
+ bookmarks = defaultBookmarks();
+ foreach (const Location &bookmark, bookmarks)
+ addBookmark(bookmark);
+}
+
+//! [1]
+
+MainWindow::~MainWindow()
+{
+ QSettings settings(QSettings::IniFormat, QSettings::UserScope,
+ QCoreApplication::organizationName(), QCoreApplication::applicationName());
+ saveBookMarks(bookmarks(), settings);
+}
+
+QAction *MainWindow::addLocation(const Location &location, QMenu *menu)
+{
+ QAction *action = menu->addAction(location.title);
+ action->setData(QVariant::fromValue(location));
+ locationActionMapper.setMapping(action, location.address);
+ connect(action, SIGNAL(triggered()), &locationActionMapper, SLOT(map()));
+ return action;
+}
+
+QList<Location> MainWindow::bookmarks() const
+{
+ QList<Location> result;
+ foreach (const QAction *action, bookmarkActions)
+ result.append(locationFromAction(action));
+ return result;
+}
+
+void MainWindow::on_actionAddBookmark_triggered()
+{
+ if (!historyActions.isEmpty()) {
+ const Location location = locationFromAction(historyActions.last());
+ if (!containsAddress(bookmarks(), location.address))
+ addBookmark(location);
+ }
}
-//! [1] //! [2]
+//! [2]
void MainWindow::on_WebBrowser_TitleChange(const QString &title)
{
+ // This is called multiple times after NavigateComplete().
+ // Add new URLs to history here.
setWindowTitle("Qt WebBrowser - " + title);
+ const QString currentAddress = address();
+ const QString historyAddress = historyActions.isEmpty() ?
+ QString() : locationFromAction(historyActions.last()).address;
+ if (currentAddress.isEmpty() || currentAddress == "about:blank" || currentAddress == historyAddress)
+ return;
+ historyActions << addLocation(Location(title, currentAddress), HistoryMenu);
+ if (historyActions.size() > 10)
+ delete historyActions.takeFirst();
}
void MainWindow::on_WebBrowser_ProgressChange(int a, int b)
@@ -138,15 +272,25 @@ void MainWindow::on_WebBrowser_BeforeNavigate()
actionStop->setEnabled(true);
}
-void MainWindow::on_WebBrowser_NavigateComplete(QString)
+void MainWindow::on_WebBrowser_NavigateComplete(const QString &url)
{
actionStop->setEnabled(false);
+ const bool blocked = addressEdit->blockSignals(true);
+ addressEdit->setText(url);
+ addressEdit->blockSignals(blocked);
}
-//! [2] //! [3]
+//! [3]
void MainWindow::on_actionGo_triggered()
{
- WebBrowser->dynamicCall("Navigate(const QString&)", addressEdit->text());
+ navigate(address());
+}
+
+//! [2]
+
+void MainWindow::navigate(const QString &url)
+{
+ WebBrowser->dynamicCall("Navigate(const QString&)", url);
}
void MainWindow::on_actionNewWindow_triggered()
@@ -184,7 +328,14 @@ void MainWindow::on_actionFileClose_triggered()
int main(int argc, char ** argv)
{
QApplication a(argc, argv);
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCoreApplication::setApplicationName("Active Qt Web Browser");
+ QCoreApplication::setOrganizationName("QtProject");
MainWindow w;
+ const QStringList arguments = QCoreApplication::arguments();
+ const QString url = arguments.size() > 1 ?
+ arguments.at(1) : QString::fromLatin1(qtProjectUrl);
+ w.navigate(url);
#if defined(Q_OS_WINCE)
w.showMaximized();
#else
diff --git a/examples/activeqt/webbrowser/mainwindow.ui b/examples/activeqt/webbrowser/mainwindow.ui
index 9af0f8e..0117771 100644
--- a/examples/activeqt/webbrowser/mainwindow.ui
+++ b/examples/activeqt/webbrowser/mainwindow.ui
@@ -114,7 +114,25 @@
<addaction name="separator" />
<addaction name="actionFileClose" />
</widget>
- <widget class="QMenu" name="unnamed" >
+ <widget class="QMenu" name="BookmarksMenu" >
+ <property name="objectName" >
+ <string notr="true" >BookmarksMenu</string>
+ </property>
+ <property name="title" >
+ <string>&amp;Bookmarks</string>
+ </property>
+ <addaction name="actionAddBookmark" />
+ <addaction name="separator" />
+ </widget>
+ <widget class="QMenu" name="HistoryMenu" >
+ <property name="objectName" >
+ <string notr="true" >HistoryMenu</string>
+ </property>
+ <property name="title" >
+ <string>Hi&amp;story</string>
+ </property>
+ </widget>
+ <widget class="QMenu" name="unnamed" >
<property name="objectName" >
<string notr="true" >unnamed</string>
</property>
@@ -125,6 +143,8 @@
<addaction name="actionAboutQt" />
</widget>
<addaction name="PopupMenu" />
+ <addaction name="BookmarksMenu" />
+ <addaction name="HistoryMenu" />
<addaction name="unnamed" />
</widget>
<action name="actionGo" >
@@ -226,6 +246,14 @@
<string>About</string>
</property>
</action>
+ <action name="actionAddBookmark" >
+ <property name="objectName" >
+ <string>actionAddBookmark</string>
+ </property>
+ <property name="text" >
+ <string>Add Bookmark</string>
+ </property>
+ </action>
<action name="actionAboutQt" >
<property name="objectName" >
<string>actionAboutQt</string>
diff --git a/examples/activeqt/webbrowser/mainwindow_windowsmobile.ui b/examples/activeqt/webbrowser/mainwindow_windowsmobile.ui
index 768dc43..29cdc6d 100644
--- a/examples/activeqt/webbrowser/mainwindow_windowsmobile.ui
+++ b/examples/activeqt/webbrowser/mainwindow_windowsmobile.ui
@@ -114,7 +114,25 @@
<addaction name="separator" />
<addaction name="actionFileClose" />
</widget>
- <widget class="QMenu" name="unnamed" >
+ <widget class="QMenu" name="BookmarksMenu" >
+ <property name="objectName" >
+ <string notr="true" >BookmarksMenu</string>
+ </property>
+ <property name="title" >
+ <string>&amp;Bookmarks</string>
+ </property>
+ <addaction name="actionAddBookmark" />
+ <addaction name="separator" />
+ </widget>
+ <widget class="QMenu" name="HistoryMenu" >
+ <property name="objectName" >
+ <string notr="true" >HistoryMenu</string>
+ </property>
+ <property name="title" >
+ <string>Hi&amp;story</string>
+ </property>
+ </widget>
+ <widget class="QMenu" name="unnamed" >
<property name="objectName" >
<string notr="true" >unnamed</string>
</property>
@@ -125,6 +143,8 @@
<addaction name="actionAboutQt" />
</widget>
<addaction name="PopupMenu" />
+ <addaction name="BookmarksMenu" />
+ <addaction name="HistoryMenu" />
<addaction name="unnamed" />
</widget>
<action name="actionGo" >
@@ -226,6 +246,14 @@
<string>About</string>
</property>
</action>
+ <action name="actionAddBookmark" >
+ <property name="objectName" >
+ <string>actionAddBookmark</string>
+ </property>
+ <property name="text" >
+ <string>Add Bookmark</string>
+ </property>
+ </action>
<action name="actionAboutQt" >
<property name="objectName" >
<string>actionAboutQt</string>
diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp
index 11c943c..d26cd6d 100644
--- a/src/activeqt/container/qaxbase.cpp
+++ b/src/activeqt/container/qaxbase.cpp
@@ -3249,6 +3249,16 @@ QT_MOC_LITERAL(12, 79, 7)
};
#undef QT_MOC_LITERAL
+/*!
+ \fn const QMetaObject *QAxBase::fallbackMetaObject() const
+ \internal
+*/
+
+/*!
+ \internal
+ \class QAxBase::qt_meta_stringdata_QAxBase_t
+*/
+
const uint QAxBase::qt_meta_data_QAxBase[] = {
// content:
diff --git a/src/activeqt/doc/src/activeqt-dumpcpp.qdoc b/src/activeqt/doc/src/activeqt-dumpcpp.qdoc
index c300ec1..b803d8e 100644
--- a/src/activeqt/doc/src/activeqt-dumpcpp.qdoc
+++ b/src/activeqt/doc/src/activeqt-dumpcpp.qdoc
@@ -48,7 +48,7 @@
library ID, or a CLSID or ProgID for an object
\row
\li -o file
- \li Writes the class declaration to \e {file}.h and meta object infomation to \e {file}.cpp
+ \li Writes the class declaration to \e {file}.h and meta object information to \e {file}.cpp
\row
\li -n namespace
\li Generate a C++ namespace \e namespace
diff --git a/src/activeqt/doc/src/qtaxcontainer.qdoc b/src/activeqt/doc/src/qtaxcontainer.qdoc
index a50658f..5620aa8 100644
--- a/src/activeqt/doc/src/qtaxcontainer.qdoc
+++ b/src/activeqt/doc/src/qtaxcontainer.qdoc
@@ -246,7 +246,7 @@
\section3 Error calling IDispatch member: Type mismatch in parameter n
A QAxBase::dynamicCall() failed - the function prototype was correct,
- but the paramter at index \c n was of the wrong type and could
+ but the parameter at index \c n was of the wrong type and could
not be coerced to the correct type.
\section3 QAxScriptManager::call(): No script provides this function
diff --git a/src/activeqt/doc/src/qtaxserver.qdoc b/src/activeqt/doc/src/qtaxserver.qdoc
index 59e38ce..79acf5d 100644
--- a/src/activeqt/doc/src/qtaxserver.qdoc
+++ b/src/activeqt/doc/src/qtaxserver.qdoc
@@ -324,7 +324,7 @@
\li QPixmap
\li IPictureDisp*
\footnote
- COM cannot marshal IPictureDisp accross process boundaries,
+ COM cannot marshal IPictureDisp across process boundaries,
so QPixmap properties cannot be called for out-of-process servers. You
can however marshal the image data via e.g. temporary files. See the
Microsoft
@@ -475,7 +475,7 @@
Any QObject subclass can be used as the type for a sub object in ActiveX, as
long as it is known to the QAxFactory. Then the type can be used in properties,
- or as the return type or paramter of a slot.
+ or as the return type or parameter of a slot.
\section2 Property Notification
@@ -527,7 +527,7 @@
\snippet doc_src_qaxserver.cpp 9
This is however not necessary as ActiveQt provides a default implementation
- of a main function. The default implemenation calls QAxFactory::startServer(),
+ of a main function. The default implementation calls QAxFactory::startServer(),
creates a QApplication instance and calls exec().
To build the ActiveX server executable run \c qmake