demos/browser/browserapplication.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the demonstration applications of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef BROWSERAPPLICATION_H
       
    43 #define BROWSERAPPLICATION_H
       
    44 
       
    45 #include <QtGui/QApplication>
       
    46 
       
    47 #include <QtCore/QUrl>
       
    48 #include <QtCore/QPointer>
       
    49 
       
    50 #include <QtGui/QIcon>
       
    51 
       
    52 QT_BEGIN_NAMESPACE
       
    53 class QLocalServer;
       
    54 QT_END_NAMESPACE
       
    55 
       
    56 class BookmarksManager;
       
    57 class BrowserMainWindow;
       
    58 class CookieJar;
       
    59 class DownloadManager;
       
    60 class HistoryManager;
       
    61 class NetworkAccessManager;
       
    62 class BrowserApplication : public QApplication
       
    63 {
       
    64     Q_OBJECT
       
    65 
       
    66 public:
       
    67     BrowserApplication(int &argc, char **argv);
       
    68     ~BrowserApplication();
       
    69     static BrowserApplication *instance();
       
    70     void loadSettings();
       
    71 
       
    72     bool isTheOnlyBrowser() const;
       
    73     BrowserMainWindow *mainWindow();
       
    74     QList<BrowserMainWindow*> mainWindows();
       
    75     QIcon icon(const QUrl &url) const;
       
    76 
       
    77     void saveSession();
       
    78     bool canRestoreSession() const;
       
    79 
       
    80     static HistoryManager *historyManager();
       
    81     static CookieJar *cookieJar();
       
    82     static DownloadManager *downloadManager();
       
    83     static NetworkAccessManager *networkAccessManager();
       
    84     static BookmarksManager *bookmarksManager();
       
    85 
       
    86 #if defined(Q_WS_MAC)
       
    87     bool event(QEvent *event);
       
    88 #endif
       
    89 
       
    90 public slots:
       
    91     BrowserMainWindow *newMainWindow();
       
    92     void restoreLastSession();
       
    93 #if defined(Q_WS_MAC)
       
    94     void lastWindowClosed();
       
    95     void quitBrowser();
       
    96 #endif
       
    97 
       
    98 private slots:
       
    99     void postLaunch();
       
   100     void openUrl(const QUrl &url);
       
   101     void newLocalSocketConnection();
       
   102 
       
   103 private:
       
   104     void clean();
       
   105     void installTranslator(const QString &name);
       
   106 
       
   107     static HistoryManager *s_historyManager;
       
   108     static DownloadManager *s_downloadManager;
       
   109     static NetworkAccessManager *s_networkAccessManager;
       
   110     static BookmarksManager *s_bookmarksManager;
       
   111 
       
   112     QList<QPointer<BrowserMainWindow> > m_mainWindows;
       
   113     QLocalServer *m_localServer;
       
   114     QByteArray m_lastSession;
       
   115     mutable QIcon m_defaultIcon;
       
   116 };
       
   117 
       
   118 #endif // BROWSERAPPLICATION_H
       
   119