diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | src/Messages.sh | 4 | ||||
| -rw-r--r-- | src/history.cpp | 2 | ||||
| -rw-r--r-- | src/history.h | 7 | ||||
| -rw-r--r-- | src/main.cpp | 43 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 481 | ||||
| -rw-r--r-- | src/mainwindow.h | 46 | ||||
| -rw-r--r-- | src/modelmenu.cpp | 2 | ||||
| -rw-r--r-- | src/modelmenu.h | 3 | ||||
| -rw-r--r-- | src/rekonqui.rc | 77 | ||||
| -rw-r--r-- | src/tabwidget.cpp | 2 | 
11 files changed, 298 insertions, 378 deletions
| diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 51790586..938c98cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,7 @@ SET( rekonq_SRCS      autosaver.cpp       browserapplication.cpp       mainwindow.cpp  +#     rekonqview.cpp      cookiejar.cpp       downloadmanager.cpp       edittableview.cpp  @@ -46,8 +47,12 @@ TARGET_LINK_LIBRARIES( rekonq      ${QT_QTWEBKIT_LIBRARY}   	${KDE4_KDEUI_LIBS}      ${KDE4_KIO_LIBS} -    ${QT_QTUITOOLS_LIBRARY} +#     ${QT_QTUITOOLS_LIBRARY}  )  INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} ) -# install(FILES kekonq.rc DESTINATION ${DATA_INSTALL_DIR}/rekonq) + +########### install files ############### + +#INSTALL( FILES rekonq.kcfg  DESTINATION  ${KCFG_INSTALL_DIR} ) +INSTALL( FILES rekonqui.rc  DESTINATION  ${DATA_INSTALL_DIR}/rekonq ) diff --git a/src/Messages.sh b/src/Messages.sh new file mode 100644 index 00000000..7edde0a1 --- /dev/null +++ b/src/Messages.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +$EXTRACTRC `find . -name \*.rc` >> rc.cpp +$XGETTEXT *.cpp -o $podir/rekonq.pot +rm -f *.cpp
\ No newline at end of file diff --git a/src/history.cpp b/src/history.cpp index 36a710b1..12a9d57f 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -668,7 +668,7 @@ void HistoryMenu::showHistoryDialog()  } -void HistoryMenu::setInitialActions(QList<KAction*> actions) +void HistoryMenu::setInitialActions(QList<QAction*> actions)  {      m_initialActions = actions;      for (int i = 0; i < m_initialActions.count(); ++i) diff --git a/src/history.h b/src/history.h index acd27192..4fac8cd6 100644 --- a/src/history.h +++ b/src/history.h @@ -38,6 +38,9 @@  #include <QWebHistoryInterface> +/** +  * Elements in this class represent an history item +  */  class HistoryItem  {  public: @@ -242,7 +245,7 @@ signals:  public:       HistoryMenu(QWidget *parent = 0); -     void setInitialActions(QList<KAction*> actions); +     void setInitialActions(QList<QAction*> actions);  protected:      bool prePopulated(); @@ -255,7 +258,7 @@ private slots:  private:      HistoryManager *m_history;      HistoryMenuModel *m_historyMenuModel; -    QList<KAction*> m_initialActions; +    QList<QAction*> m_initialActions;  }; diff --git a/src/main.cpp b/src/main.cpp index 7963405d..fb9bf3de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,33 +24,32 @@  #include <KAboutData>  #include <KCmdLineArgs> +static const char description[] = +    I18N_NOOP("KDE Browser Webkit Based"); + +static const char version[] = "0.0.2"; -// really simple writing main files today..  int main(int argc, char **argv)  { -    KAboutData aboutData( -        "rekonq", -        0,  -        ki18n("rekonq"),  -        "0.0.1",  -        ki18n("A KDE browser webkit based"), -        KAboutData::License_GPL, -        ki18n("Copyright (c) 2008 Andrea Diamantini"), -        KLocalizedString(), -        "http://www.adjam.org", -        "adjam7@gmail.com"  // bug report mail -    ); +    KAboutData about(   "rekonq",  +                                    0,  +                                    ki18n("rekonq"),  +                                    version,  +                                    ki18n(description), +                                    KAboutData::License_GPL,  +                                    ki18n("(C) 2008 Andrea Diamantini"),  +                                    KLocalizedString(),  +                                    "http://www.adjam.org", +                                    "adjam7@gmail.com" +                                ); + +    about.addAuthor(       ki18n("Andrea Diamantini"),  +                                    KLocalizedString(),  +                                    "adjam7@gmail.com"  +                            ); -    aboutData.addAuthor( -        ki18n("Andrea Diamantini"),  -        ki18n("rekonq author"),  -        "adjam7@gmail.com" -    ); -     -    aboutData.setProgramIconName("applications-internet"); +    KCmdLineArgs::init(argc, argv, &about); -    KCmdLineArgs::init( argc, argv, &aboutData ); -          KCmdLineOptions options;      options.add( "+URL" , ki18n("Location to open") );      KCmdLineArgs::addCmdLineOptions( options ); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b57f5379..eb0543e9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -19,9 +19,10 @@   * ============================================================ */ -// Local Includes +// Self Includes  #include "mainwindow.h" -#include "autosaver.h" + +// Local Includes  #include "browserapplication.h"  #include "downloadmanager.h"  #include "history.h" @@ -54,365 +55,209 @@  #include <QDebug> -MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) -    : KMainWindow(parent, flags) -    , m_tabWidget(new TabWidget(this)) -    , m_autoSaver(new AutoSaver(this)) -    , m_historyBack(0) -    , m_historyForward(0) -    , m_stop(0) -    , m_reload(0) +MainWindow::MainWindow() +    : KXmlGuiWindow() +    , m_tabWidget( new TabWidget(this) )  { -    // delete widget accepting close event -    setAttribute(Qt::WA_DeleteOnClose, true); - -    setupMenu(); -    setupToolBar(); +    // accept dnd +    setAcceptDrops(true); -    QWidget *centralWidget = new QWidget(this); +    m_tabWidget->newTab(); -    QVBoxLayout *layout = new QVBoxLayout; -    layout->setSpacing(0); -    layout->setMargin(0); -    addToolBarBreak(); -    layout->addWidget(m_tabWidget); +    // tell the KXmlGuiWindow that this is indeed the main widget +    setCentralWidget(m_tabWidget);      // Find Bar      m_findBar = new FindBar(this);      connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) );  -    centralWidget->setLayout(layout); -	setCentralWidget(centralWidget); -      connect(m_tabWidget, SIGNAL( loadPage(const QString &) ), this, SLOT( loadPage(const QString &) ) );      connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) );      connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) );      connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) );      connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); -    connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); +//     connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) );      connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) );      connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) );      connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) );      connect(m_tabWidget, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); -    connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) ); +//     connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) );      connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) );      slotUpdateWindowTitle(); -    loadDefaultState(); -    m_tabWidget->newTab(); -} +// -------------------------------------------------------------------------------------------------------------------------------- -MainWindow::~MainWindow() -{ -    m_autoSaver->changeOccurred(); -    m_autoSaver->saveIfNeccessary(); -    delete m_navigationBar; -} +    // then, setup our actions +    setupActions(); +    // add a status bar +    statusBar()->show(); -void MainWindow::loadDefaultState() -{ -    KConfig config("rekonqrc"); -    KConfigGroup group1 = config.group("MainWindow");    -    QByteArray data = group1.readEntry(QString("defaultState"), QByteArray() ); -    restoreState(data);  -} +    // a call to KXmlGuiWindow::setupGUI() populates the GUI +    // with actions, using KXMLGUI. +    // It also applies the saved mainwindow settings, if any, and ask the +    // mainwindow to automatically save settings if changed: window size, +    // toolbar position, icon size, etc. +    setupGUI(); +    // setup history & bookmarks menus +    setupCustomMenu(); -void MainWindow::save() -{ -    BrowserApplication::instance()->saveSession(); - -    KConfig config("rekonqrc"); -    KConfigGroup group1 = config.group("MainWindow");    -    QByteArray data = saveState(); -    group1.writeEntry( QString("defaultState"), data ); - -    KConfigGroup group2 = config.group("navigation toobar"); -    m_navigationBar->saveSettings( group2 ); -} - - -static const qint32 MainWindowMagic = 0xba; +    // setting up custom widgets.. +    KToolBar *navigationBar = toolBar( "mainToolBar" ); +    navigationBar->addWidget( m_tabWidget->lineEditStack() ); +    m_searchBar = new SearchBar( this ); +    connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); +    navigationBar->addWidget(m_searchBar); -QByteArray MainWindow::saveState() const -{ -    int version = 2; -    QByteArray data; -    QDataStream stream(&data, QIODevice::WriteOnly); - -    stream << qint32(MainWindowMagic); -    stream << qint32(version); - -    stream << size(); -    stream << KToolBar::toolBarsLocked(); -    bool b = true; // statusBar()->isVisible() ;    FIXME -    stream << b; -    stream << QByteArray(); -    return data;  } - -void MainWindow::restoreState(const QByteArray &state) +MainWindow::~MainWindow()  { -    int version = 2; -    QByteArray sd = state; -    QDataStream stream(&sd, QIODevice::ReadOnly); -    if ( stream.atEnd() ) -    { -        return; -    } - -    qint32 marker; -    qint32 v; -    stream >> marker; -    stream >> v; -    if (marker != MainWindowMagic || v != version) -    { -        return; -    } - -    QSize size; -    bool showStatusbar; -    bool toolbarsLocked; -    QByteArray tabState; - -    stream >> size; -    stream >> toolbarsLocked; -    stream >> showStatusbar;  - -    resize(size); -    statusBar()->setVisible(showStatusbar); -    updateStatusbarActionText(showStatusbar); - -    KToolBar::setToolBarsLocked ( toolbarsLocked ); -    return;  } -void MainWindow::setupMenu() +void MainWindow::setupActions()  { -    //  ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- -    KMenu *fileMenu = (KMenu *) menuBar()->addMenu( i18n("&File") ); - -    fileMenu->addAction( KStandardAction::openNew(this, SLOT( slotFileNew() ) , this ) ); -    fileMenu->addAction( KStandardAction::open( this, SLOT( slotFileOpen() ), this ) ); -    fileMenu->addAction( i18n("Open Location"), this, SLOT( slotSelectLineEdit() ) ); -    fileMenu->addSeparator(); - -    fileMenu->addAction( m_tabWidget->newTabAction() ); -    fileMenu->addAction( m_tabWidget->closeTabAction() ); -    fileMenu->addSeparator(); +    KAction *a; -    fileMenu->addAction( KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), this ) ); -    fileMenu->addSeparator(); +    // Standard Actions +    KStandardAction::openNew(this, SLOT( slotFileNew() ) , actionCollection() ); +    KStandardAction::open( this, SLOT( slotFileOpen() ), actionCollection() ); +    KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), actionCollection() ); +    KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), actionCollection() ); +    KStandardAction::print( this, SLOT( slotFilePrint() ), actionCollection() ); +    KStandardAction::quit( this , SLOT( close() ), actionCollection() );  +    KStandardAction::find(this, SLOT( slotViewFindBar() ) , actionCollection() ); +    KStandardAction::findNext(this, SLOT( slotFindNext() ) , actionCollection() ); +    KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , actionCollection() ); +    KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, actionCollection() ); +    KStandardAction::home( this, SLOT( slotHome() ), actionCollection() ); -    fileMenu->addAction( KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), this ) ); -    fileMenu->addAction( KStandardAction::print( this, SLOT(slotFilePrint()), this) ); -    fileMenu->addSeparator(); +    a = KStandardAction::redisplay( this, 0, actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::Reload ); -    KAction *action = (KAction *) fileMenu->addAction( i18n("Private &Browsing..."), this, SLOT( slotPrivateBrowsing() ) ); -    action->setCheckable(true); -    fileMenu->addSeparator(); +    a = KStandardAction::back( this, 0, actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::Back ); -    fileMenu->addAction( KStandardAction::quit( this , SLOT( close() ), this ) );  +    a = KStandardAction::forward( this, 0, actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::Forward ); -    //  ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- -    KMenu *editMenu = (KMenu *) menuBar()->addMenu( i18n("&Edit") ); +    a = KStandardAction::undo( this , 0 , actionCollection() ); +    m_tabWidget->addWebAction( a , QWebPage::Undo ); -    KAction *m_undo = KStandardAction::undo( this , 0 , this ); -    editMenu->addAction( m_undo ); -    m_tabWidget->addWebAction(m_undo, QWebPage::Undo); +    a = KStandardAction::redo( this , 0 , actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::Redo ); -    KAction *m_redo = KStandardAction::redo( this , 0 , this ); -    editMenu->addAction( m_redo ); -    m_tabWidget->addWebAction(m_redo, QWebPage::Redo); +    a = KStandardAction::cut( this , 0 , actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::Cut ); -    editMenu->addSeparator(); +    a = KStandardAction::copy( this , 0 , actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::Copy ); -    KAction *m_cut = KStandardAction::cut( this , 0 , this ); -    editMenu->addAction( m_cut ); -    m_tabWidget->addWebAction(m_cut, QWebPage::Cut); +    a = KStandardAction::paste( this , 0 , actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::Paste ); -    KAction *m_copy = KStandardAction::copy( this , 0 , this ); -    editMenu->addAction( m_copy ); -    m_tabWidget->addWebAction(m_copy, QWebPage::Copy); +    a = KStandardAction::selectAll( this , 0 , actionCollection() ); +    m_tabWidget->addWebAction( a, QWebPage::SelectEndOfDocument ); -    KAction *m_paste = KStandardAction::paste( this , 0 , this ); -    editMenu->addAction( m_paste ); -    m_tabWidget->addWebAction(m_paste, QWebPage::Paste); +    // stop reload Action  +    m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); +    actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); -    editMenu->addSeparator(); +    // Custom Actions +    a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); +    a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); +    actionCollection()->addAction( QLatin1String("stop"), a ); +    m_tabWidget->addWebAction( a, QWebPage::Stop); +     +    a = new KAction( KIcon(), i18n("Open Location"), this);  +    actionCollection()->addAction( QLatin1String("open location"), a ); +    connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotOpenLocation() ) ); -    KAction *m_selectall = KStandardAction::selectAll( this , 0 , this ); -    editMenu->addAction( m_selectall ); -    m_tabWidget->addWebAction(m_selectall, QWebPage::SelectEndOfDocument ); +    actionCollection()->addAction( QLatin1String("new tab"), m_tabWidget->newTabAction() ); +    actionCollection()->addAction( QLatin1String("close tab"), m_tabWidget->closeTabAction() ); -    editMenu->addSeparator(); +    a = new KAction( i18n("Private &Browsing..."), this ); +    a->setCheckable(true); +    actionCollection()->addAction( i18n("private browsing"), a ); +    connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotPrivateBrowsing() ) ); -    editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); -    editMenu->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); -    editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); +    a = new KAction( i18n("&Bigger"), this ); +    a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Plus) ); +    actionCollection()->addAction( QLatin1String("bigger font"), a ); +    connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextBigger() ) ); -    //  ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- -    KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); +    a = new KAction( i18n("&Normal"), this ); +    a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_0) ); +    actionCollection()->addAction( QLatin1String("normal font"), a ); +    connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextNormal() ) ); -    m_viewStatusbar = KStandardAction::showStatusbar( this, SLOT(slotViewStatusbar() ), this); -    viewMenu->addAction(m_viewStatusbar); +    a = new KAction( i18n("&Smaller"), this ); +    a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Minus) ); +    actionCollection()->addAction( QLatin1String("smaller font"), a ); +    connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextSmaller() ) ); -    viewMenu->addSeparator(); +    a = new KAction( i18n("Page S&ource"), this ); +    actionCollection()->addAction( QLatin1String("page source"), a ); +    connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewPageSource() ) ); -    m_stop = (KAction *) viewMenu->addAction( KIcon( "process-stop" ), i18n("&Stop") ); -    m_stop->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); -    m_tabWidget->addWebAction(m_stop, QWebPage::Stop); +    a = new KAction( KIcon( "kget" ), i18n("Downloads"), this ); +    actionCollection()->addAction( QLatin1String("downloads"), a); +    connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotDownloadManager() ) ); -    m_reload = (KAction *) viewMenu->addAction( KIcon("view-refresh"), i18n("Reload Page") ); -    m_reload->setShortcut(QKeySequence::Refresh); -    m_tabWidget->addWebAction(m_reload, QWebPage::Reload); +    a = new KAction( KIcon("page-zoom"), i18n("Enable Web &Inspector"), this ); +    a->setCheckable(true); +    actionCollection()->addAction( QLatin1String("web inspector"), a ); +    connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotToggleInspector(bool) ) ); -    viewMenu->addSeparator(); +    // =================================================================================================================== +    // =================================================================================================================== +    // FIXME -    KMenu *fontMenu = new KMenu( i18n("Make Text..."), this ); -    fontMenu->addAction( i18n("&Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); -    fontMenu->addAction( i18n("&Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); -    fontMenu->addAction( i18n("&Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); - -    viewMenu->addMenu( fontMenu ); - -    viewMenu->addSeparator(); - -    // TODO set encoding +    KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); +    m_historyBackMenu = new KMenu(this); +    historyBack->setMenu(m_historyBackMenu); +    connect(historyBack, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenPrevious() ) ); +    connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); +    connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); +    actionCollection()->addAction( QLatin1String("history back"), historyBack); -    viewMenu->addAction( i18n("Page S&ource"), this, SLOT( slotViewPageSource() ), i18n("Ctrl+Alt+U")); +    KAction *historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); +    connect(historyForward, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenNext() ) ); +    actionCollection()->addAction( QLatin1String("history forward"), m_historyForward ); +} -    KToggleFullScreenAction *tfsa = KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, this); -    viewMenu->addAction( tfsa ); -    //  ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- +void MainWindow::setupCustomMenu() +{ +    //  ------------------------------------------------------------- HISTORY MENU--------------------------------------------------------------------------------------------------      HistoryMenu *historyMenu = new HistoryMenu(this);      connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&)));      connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&)));      historyMenu->setTitle( i18n("Hi&story") );      menuBar()->addMenu(historyMenu); -    QList<KAction*> historyActions; - -    m_historyBack = new KAction( i18n("Back"), this); -    m_historyBack->setShortcut( KShortcut( QKeySequence::Back ) );  -    m_tabWidget->addWebAction( m_historyBack, QWebPage::Back ); -    m_historyBack->setIconVisibleInMenu(false); - -    m_historyForward = new KAction( i18n("Forward"), this); -    m_historyForward->setShortcut( KShortcut( QKeySequence::Forward ) ); -    m_tabWidget->addWebAction( m_historyForward, QWebPage::Forward ); -    m_historyForward->setIconVisibleInMenu(false); +    QList<QAction*> historyActions; -    historyActions.append( m_historyBack ); -    historyActions.append( m_historyForward ); -    historyActions.append( KStandardAction::home(this, SLOT( slotHome() ) , this ) ); +    historyActions.append( actionCollection()->action("Back") ); +    historyActions.append( actionCollection()->action("Forward") ); +    historyActions.append( actionCollection()->action("Home") );      historyActions.append( m_tabWidget->recentlyClosedTabsAction() );      historyMenu->setInitialActions(historyActions); +    // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - - -    //  ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- - +    // --------------------------------------------- BOOKMARKS  MENU -----------------------------------------------------------------------------------------------------      BookmarksMenu *bookmarksMenu = new BookmarksMenu( this );      bookmarksMenu->setTitle( i18n("&Bookmarks") ); -    menuBar()->addMenu( bookmarksMenu ); - -    //  ------------------------------------------------------------- TOOLS ------------------------------------------------------------------------------------------------------ -    KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); - -    toolsMenu->addAction( i18n("Downloads"), this, SLOT( slotDownloadManager() ), i18n("Alt+Ctrl+D") ); - -    toolsMenu->addSeparator(); - -    action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); -    action->setCheckable(true); - -    //  ------------------------------------------------------------- SETTINGS ------------------------------------------------------------------------------------------------------ -    KMenu *settingsMenu = (KMenu *) menuBar()->addMenu( i18n("&Settings") ); - -    settingsMenu->addAction( KStandardAction::keyBindings( this, SLOT( configureShortcuts() ), this ) );    //FIXME need new slot and actionCollection !! -    settingsMenu->addAction( KStandardAction::preferences(this, SLOT( slotPreferences() ) , this ) ); - -    //  ------------------------------------------------------------- HELP  -------------------------------------------------------------------------------------------------- -   menuBar()->addMenu( helpMenu() ); -} - - -void MainWindow::setupToolBar() -{ -    m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, true);  - -    m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); -    m_historyBackMenu = new KMenu(this); -    m_historyBack->setMenu(m_historyBackMenu); -    connect(m_historyBack, SIGNAL( triggered() ), this, SLOT( slotOpenPrevious() ) ); -    connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); -    connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); -    m_navigationBar->addAction(m_historyBack); - -    m_historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); -    connect(m_historyForward, SIGNAL( triggered() ), this, SLOT( slotOpenNext() ) ); -    m_navigationBar->addAction(m_historyForward); - -    m_stopReload = new KAction( KIcon("view-refresh"), i18n("Reload"), this); -    m_navigationBar->addAction(m_stopReload); - -    m_goHome = new KAction( KIcon( "go-home" ), i18n("Home"),this); -    m_navigationBar->addAction(m_goHome); -    connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); - -    m_navigationBar->addWidget( m_tabWidget->lineEditStack() ); - -    m_searchBar = new SearchBar( m_navigationBar ); -    connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); -    m_navigationBar->addWidget(m_searchBar); - -    // UI settings -    setContextMenuPolicy( Qt::PreventContextMenu ); - -    // setting initial style (if user hasn't decided something else) -    m_navigationBar->setIconDimensions(22); -    m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly ); - -    KConfig config("rekonqrc"); -    KConfigGroup group = config.group("navigation toobar"); -    if ( group.exists() ) -    { -        m_navigationBar->applySettings( group ); -    } -} - - -void MainWindow::updateStatusbarActionText(bool visible) -{ -    m_viewStatusbar->setText(!visible ? i18n("Show Status Bar") : i18n("Hide Status Bar")); -} - - -void MainWindow::slotViewStatusbar() -{ -    if (statusBar()->isVisible())  -    { -        updateStatusbarActionText(false); -        statusBar()->close(); -    }  -    else  -    { -        updateStatusbarActionText(true); -        statusBar()->show(); -    } -    m_autoSaver->changeOccurred(); +    menuBar()->addMenu(bookmarksMenu ); +    // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------  } -  KUrl MainWindow::guessUrlFromString(const QString &string)  {      QString urlStr = string.trimmed(); @@ -480,7 +325,7 @@ void MainWindow::slotDownloadManager()  } -void MainWindow::slotSelectLineEdit() +void MainWindow::slotOpenLocation()  {      m_tabWidget->currentLineEdit()->selectAll();      m_tabWidget->currentLineEdit()->setFocus(); @@ -607,22 +452,22 @@ void MainWindow::slotPrivateBrowsing()  } -void MainWindow::closeEvent(QCloseEvent *event) -{ -    if (m_tabWidget->count() > 1)  -    { -        int ret = KMessageBox::warningYesNo(this,  -                                                         i18n("Are you sure you want to close the window?" "  There are %1 tab open" , m_tabWidget->count() ) , -                                                        i18n("Closing") ); -        if (ret == KMessageBox::No)  -        { -            event->ignore(); -            return; -        } -    } -    event->accept(); -    deleteLater(); -} +// void MainWindow::closeEvent(QCloseEvent *event) +// { +//     if (m_tabWidget->count() > 1)  +//     { +//         int ret = KMessageBox::warningYesNo(this,  +//                                                          i18n("Are you sure you want to close the window?" "  There are %1 tab open" , m_tabWidget->count() ) , +//                                                         i18n("Closing") ); +//         if (ret == KMessageBox::No)  +//         { +//             event->ignore(); +//             return; +//         } +//     } +//     event->accept(); +//     deleteLater(); +// }  void MainWindow::slotFind(const QString & search) @@ -685,7 +530,7 @@ void MainWindow::slotViewTextSmaller()  // TODO improve this -void MainWindow::slotViewFullScreen(bool makeFullScreen) +void MainWindow::slotViewFullScreen( bool makeFullScreen )  {      KToggleFullScreenAction::setFullScreen( this, makeFullScreen );  } @@ -733,10 +578,14 @@ void MainWindow::slotToggleInspector(bool enable)  void MainWindow::slotSwapFocus()  { -    if (currentTab()->hasFocus()) +    if ( currentTab()->hasFocus() ) +    {          m_tabWidget->currentLineEdit()->setFocus(); +    }      else +    {          currentTab()->setFocus(); +    }  } @@ -764,23 +613,29 @@ WebView *MainWindow::currentTab() const  } +// FIXME: this actually doesn't work properly..  void MainWindow::slotLoadProgress(int progress)  {      if (progress < 100 && progress > 0)       { -        disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); -        if (m_stopIcon.isNull()) -            m_stopIcon = KIcon( "process-stop" ); -        m_stopReload->setIcon(m_stopIcon); -        connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); +//         disconnect(m_stopReload, SIGNAL( triggered( bool ) ), m_reload, SLOT( trigger() ) ); +//         m_stopReload->setIcon( KIcon( "process-stop" ) ); +//         connect(m_stopReload, SIGNAL( triggered( bool ) ), m_stop, SLOT( trigger() ) ); + +        disconnect( m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "redisplay" ) , SIGNAL( triggered() ) ); +         m_stopReload->setIcon( KIcon( "process-stop" ) ); +        connect(m_stopReload, SIGNAL( triggered(bool ) ), actionCollection()->action( "stop" ), SLOT( triggered() ) );          m_stopReload->setToolTip( i18n("Stop loading the current page") );      }       else       { -        disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); -        m_stopReload->setIcon( KIcon("view-refresh") ); -        connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); -        m_stopReload->setToolTip( i18n("Reload the current page") ); +//         disconnect(m_stopReload, SIGNAL( triggered( bool ) ), m_stop, SLOT( trigger() ) ); +//         m_stopReload->setIcon( KIcon("view-refresh") ); +//         connect(m_stopReload, SIGNAL( triggered( bool ) ), m_reload, SLOT( trigger() ) ); +        disconnect( m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "stop" ) , SIGNAL( triggered( ) ) ); +         m_stopReload->setIcon( KIcon( "view-refresh" ) ); +        connect(m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "redisplay" ), SLOT( triggered() ) ); +         m_stopReload->setToolTip( i18n("Reload the current page") );      }  } diff --git a/src/mainwindow.h b/src/mainwindow.h index 6f78fd59..aa8e3d65 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -28,7 +28,7 @@  // KDE Includes  #include <KUrl> -#include <KMainWindow> +#include <KXmlGuiWindow>  #include <KIcon>  #include <KToolBar>  #include <KAction> @@ -36,7 +36,6 @@  #include <KMenu> -class AutoSaver;  class QWebFrame;  class TabWidget;  class WebView; @@ -45,21 +44,21 @@ class WebView;      The MainWindow of the Browser Application.      Handles the tab widget and all the actions  */ -class MainWindow : public KMainWindow  +class MainWindow : public KXmlGuiWindow   {      Q_OBJECT  public: -    MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); +    MainWindow();      ~MainWindow();      static KUrl guessUrlFromString(const QString &url);      TabWidget *tabWidget() const;      WebView *currentTab() const; - -    QByteArray saveState() const; -    void restoreState(const QByteArray &state); +private: +    void setupActions(); +    void setupCustomMenu();  public slots:      void loadPage(const QString &url); @@ -68,12 +67,7 @@ public slots:      void slotFindNext();      void slotFindPrevious(); -protected: -    void closeEvent(QCloseEvent *event); -  private slots: -    void save(); -      void slotLoadProgress(int);      void slotUpdateStatusbar(const QString &string);      void slotUpdateWindowTitle(const QString &title = QString()); @@ -91,14 +85,13 @@ private slots:      void slotViewTextBigger();      void slotViewTextNormal();      void slotViewTextSmaller(); -    void slotViewStatusbar();      void slotViewPageSource();      void slotViewFullScreen(bool enable);      void slotViewFindBar();      void slotToggleInspector(bool enable);      void slotDownloadManager(); -    void slotSelectLineEdit(); +    void slotOpenLocation();      void slotAboutToShowBackMenu(); @@ -113,36 +106,19 @@ private slots:      void printRequested(QWebFrame *frame);      void geometryChangeRequested(const QRect &geometry); -private: -    void loadDefaultState(); -    void setupMenu(); -    void setupToolBar(); -    void updateStatusbarActionText(bool visible);  private: - -    KToolBar *m_navigationBar;      SearchBar *m_searchBar; -    TabWidget *m_tabWidget; -    AutoSaver *m_autoSaver; +    FindBar *m_findBar; -    KAction *m_historyBack;      KMenu *m_historyBackMenu; -    KAction *m_historyForward;      KMenu *m_windowMenu; -    KAction *m_stop; -    KAction *m_reload; -    KAction *m_stopReload; -    KAction *m_goHome; -    KToggleAction *m_viewStatusbar; -    KAction *m_restoreLastSession; - -    KIcon m_reloadIcon; -    KIcon m_stopIcon; +    QAction *m_stopReload; -    FindBar *m_findBar;      QString m_lastSearch; + +    TabWidget *m_tabWidget;  };  #endif // MAINWINDOW_H diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp index f2cd0189..965ef0a4 100644 --- a/src/modelmenu.cpp +++ b/src/modelmenu.cpp @@ -22,7 +22,7 @@  ModelMenu::ModelMenu(QWidget * parent) -    : QMenu(parent) +    : KMenu(parent)      , m_maxRows(7)      , m_firstSeparator(-1)      , m_maxWidth(-1) diff --git a/src/modelmenu.h b/src/modelmenu.h index fe08e673..16c413af 100644 --- a/src/modelmenu.h +++ b/src/modelmenu.h @@ -29,9 +29,10 @@  // KDE Includes  #include <KIcon>  #include <KAction> +#include <KMenu>  // A QMenu that is dynamically populated from a QAbstractItemModel -class ModelMenu : public QMenu +class ModelMenu : public KMenu  {      Q_OBJECT diff --git a/src/rekonqui.rc b/src/rekonqui.rc new file mode 100644 index 00000000..32397b16 --- /dev/null +++ b/src/rekonqui.rc @@ -0,0 +1,77 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="rekonq" version="1"> +<MenuBar> +<!--  ============ FILE menu =========== --> +  <Menu name="file" noMerge="1"><text>&File</text> +    <Action name="file_new" /> +    <Action name="file_open" /> +    <Action name="open location" /> +    <Separator/> +    <Action name="new tab" /> +    <Action name="close tab" /> +    <Separator/> +    <Action name="file_save_as" /> +    <Separator/> +    <Action name="file_print_preview" /> +    <Action name="file_print" /> +    <Separator/> +    <Action name="private browsing" /> +    <Separator/> +    <Action name="file_quit" /> +  </Menu> +  <!--  ============ EDIT menu =========== --> +  <Menu name="edit" noMerge="1"><text>&Edit</text> +    <Action name="edit_undo" /> +    <Action name="edit_redo" /> +    <Separator/> +    <Action name="edit_cut" /> +    <Action name="edit_copy" /> +    <Action name="edit_paste" /> +    <Separator/> +    <Action name="edit_select_all" /> +    <Separator/> +    <Action name="edit_find" /> +    <Action name="edit_find_next" /> +    <Action name="edit_find_prev" /> +  </Menu> +  <!--  ============ VIEW menu =========== --> +  <Menu name="view" noMerge="1"><text>&View</text> +    <Action name="view_redisplay" /> +    <Separator/> +        <Menu name="fontmenu"> +         <text>make text..</text> +        <Action name="bigger font" /> +        <Action name="normal font" /> +        <Action name="smaller font" /> +        </Menu> +    <Separator/> +    <Action name="page source" /> +    <Action name="fullscreen" /> +  </Menu> +<!--  ============ TOOLS menu =========== --> +    <Menu name="tools"> +    <Action name="downloads" /> +    <Action name="web inspector" /> +</Menu> +<!--  ============ SETTINGS menu =========== --> +<Menu name="settings" noMerge="1"> +        <text>&Settings</text> +        <Action name="options_show_statusbar"/> +        <Separator/> +        <Action name="options_configure_keybinding"/> +        <Action name="options_configure_toolbars"/> +        <Action name="options_configure"/> +    </Menu> +</MenuBar> + +<!--  ============ Main ToolBar =========== --> + +<ToolBar name="mainToolBar" fullWidth="true" iconText="iconOnly" position="top" noMerge="1"> +    <text>Main Toolbar</text> +    <Action name="history back" /> +    <Action name="history forward" /> +    <Action name="stop reload" /> +    <Action name="go_home" /> +</ToolBar> + +</kpartgui> diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 08ec1212..3a26266b 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -229,7 +229,7 @@ TabWidget::TabWidget(QWidget *parent)      setTabBar(m_tabBar);      // Actions -    m_newTabAction = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); +    m_newTabAction = new KAction( KIcon("tab-new"), i18n("New &Tab"), this);      m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) );      m_newTabAction->setIconVisibleInMenu(false);      connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); | 
