From 16072a8703434afc39acf991673cf932747d80c6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 22 Aug 2009 22:51:17 +0200 Subject: Removed MenuBar. First steps.. --- src/CMakeLists.txt | 1 - src/findbar.cpp | 4 +-- src/findbar.h | 5 ++- src/mainview.cpp | 1 - src/mainwindow.cpp | 77 +++++++++++++++++++++++++--------------- src/mainwindow.h | 13 ++++--- src/rekonqui.rc | 102 ----------------------------------------------------- 7 files changed, 62 insertions(+), 141 deletions(-) delete mode 100644 src/rekonqui.rc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d4e513fd..67a0c8df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,4 +71,3 @@ TARGET_LINK_LIBRARIES ( rekonq INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} ) INSTALL( FILES rekonq.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) -INSTALL( FILES rekonqui.rc DESTINATION ${DATA_INSTALL_DIR}/rekonq ) diff --git a/src/findbar.cpp b/src/findbar.cpp index 6d108a15..4ec93d87 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include // Qt Includes @@ -47,7 +47,7 @@ #include -FindBar::FindBar(KXmlGuiWindow *mainwindow) +FindBar::FindBar(KMainWindow *mainwindow) : QWidget(mainwindow) , m_lineEdit(new KLineEdit(this)) , m_matchCase(new QCheckBox(i18n("&Match case"), this)) diff --git a/src/findbar.h b/src/findbar.h index 6d92a645..0818d010 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -38,7 +38,7 @@ #include // Forward Declarations -class KXmlGuiWindow; +class KMainWindow; class QKeyEvent; class QString; @@ -48,7 +48,7 @@ class FindBar : public QWidget Q_OBJECT public: - FindBar(KXmlGuiWindow *mainwindow); + FindBar(KMainWindow *mainwindow); ~FindBar(); KLineEdit *lineEdit() const; bool matchCase() const; @@ -71,4 +71,3 @@ private: }; #endif - diff --git a/src/mainview.cpp b/src/mainview.cpp index 2b6d294c..9b3dfc21 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -415,7 +415,6 @@ void MainView::slotReloadAllTabs() void MainView::windowCloseRequested() { - WebPage *webPage = qobject_cast(sender()); WebView *webView = qobject_cast(webPage->view()); int index = webViewIndex(webView); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8a84b844..f527a6cb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -88,11 +88,15 @@ MainWindow::MainWindow() - : KXmlGuiWindow() + : KMainWindow() , m_view(new MainView(this)) , m_findBar(new FindBar(this)) , m_sidePanel(0) + , m_ac( new KActionCollection(this) ) { + // enable window size "auto-save" + setAutoSaveSettings(); + // updating rekonq configuration slotUpdateConfiguration(); @@ -116,27 +120,20 @@ MainWindow::MainWindow() // then, setup our actions setupActions(); - // setting up toolbars && location bar: this has to be done BEFORE setupGUI!! - setupBars(); - // Bookmark Menu KActionMenu *bmMenu = Application::bookmarkProvider()->bookmarkActionMenu(); bmMenu->setIcon(KIcon("rating")); actionCollection()->addAction(QLatin1String("bookmarksActionMenu"), bmMenu); ((KActionMenu *)actionByName("bookmarksActionMenu"))->setDelayed(false); - // Side Panel: this has to be done BEFORE setupGUI!! + // setting Side Panel setupSidePanel(); - // setting up rekonq tools: to be done BEFORE setupGUI! + // setting up rekonq tools setupTools(); - - // 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(); + + // setting up rekonq toolbar(s) + setupToolbar(); // no more status bar.. setStatusBar(0); @@ -158,11 +155,27 @@ SidePanel *MainWindow::sidePanel() } -void MainWindow::postLaunch() +void MainWindow::setupToolbar() { - // setup history menu: this has to be done AFTER setupGUI!! - setupHistoryMenu(); + KToolBar *mainToolBar = new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea); + mainToolBar->setContextMenuPolicy(Qt::PreventContextMenu); + mainToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); + mainToolBar->addAction( actionByName(KStandardAction::name(KStandardAction::Back)) ); + mainToolBar->addAction( actionByName(KStandardAction::name(KStandardAction::Forward)) ); + mainToolBar->addSeparator(); + mainToolBar->addAction( actionByName("stop_reload") ); + mainToolBar->addAction( actionByName(KStandardAction::name(KStandardAction::Home)) ); + mainToolBar->addAction( actionByName("url_bar") ); + mainToolBar->addAction( actionByName("bookmarksActionMenu") ); + mainToolBar->addAction( actionByName("rekonq_tools") ); + + KToolBar::setToolBarsEditable(false); + KToolBar::setToolBarsLocked(true); +} + +void MainWindow::postLaunch() +{ // --------- connect signals and slots connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); @@ -183,7 +196,8 @@ void MainWindow::postLaunch() // accept d'n'd setAcceptDrops(true); - + + // set CookieJar window Id const qlonglong winId = window()->winId(); Application::cookieJar()->setWindowId(winId); Application::networkAccessManager()->metaData().insert("window-id", QString::number(winId)); @@ -198,7 +212,13 @@ QSize MainWindow::sizeHint() const } -void MainWindow::setupBars() +KActionCollection *MainWindow::actionCollection () const +{ + return m_ac; +} + + +void MainWindow::setupActions() { KAction *a; @@ -211,12 +231,6 @@ void MainWindow::setupBars() // bookmarks bar KAction *bookmarkBarAction = Application::bookmarkProvider()->bookmarkToolBarAction(); a = actionCollection()->addAction(QLatin1String("bookmarks_bar"), bookmarkBarAction); -} - - -void MainWindow::setupActions() -{ - KAction *a; // Standard Actions KStandardAction::open(this, SLOT(slotFileOpen()), actionCollection()); @@ -335,13 +349,21 @@ void MainWindow::setupActions() void MainWindow::setupTools() { - KActionMenu *toolsMenu = new KActionMenu(KIcon("configure"), i18n("rekonq tools"), this); + KActionMenu *toolsMenu = new KActionMenu(KIcon("configure"), i18n("&Tools"), this); toolsMenu->setDelayed(false); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::PrintPreview))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); + KActionMenu *fontMenu = new KActionMenu(KIcon("page-zoom"), i18n("Zoom"), this); + fontMenu->addAction(actionByName(QLatin1String("smaller_font"))); + fontMenu->addAction(actionByName(QLatin1String("normal_font"))); + fontMenu->addAction(actionByName(QLatin1String("bigger_font"))); + toolsMenu->addAction(fontMenu); + + toolsMenu->addSeparator(); + KActionMenu *webMenu = new KActionMenu(KIcon("applications-development-web"), i18n("Web Development"), this); webMenu->addAction(actionByName(QLatin1String("web_inspector"))); webMenu->addAction(actionByName(QLatin1String("page_source"))); @@ -359,8 +381,7 @@ void MainWindow::setupTools() toolsMenu->addSeparator(); - // TODO: decide if re-enable this when rekonq docs will be written - // toolsMenu->addAction(KStandardAction::helpContents(this, SLOT(appHelpActivated()), actionCollection())); + toolsMenu->addAction(helpMenu()->menuAction()); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences))); // adding rekonq_tools to rekonq actionCollection @@ -875,7 +896,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) return; } - KXmlGuiWindow::keyPressEvent(event); + KMainWindow::keyPressEvent(event); } diff --git a/src/mainwindow.h b/src/mainwindow.h index b7f9bae1..a2031692 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -36,7 +36,9 @@ #include "webview.h" // KDE Includes -#include +#include +#include +#include // Forward Declarations class QWebFrame; @@ -55,7 +57,7 @@ class WebView; * It handles the menus, toolbars, and status bars. * */ -class MainWindow : public KXmlGuiWindow +class MainWindow : public KMainWindow { Q_OBJECT @@ -67,12 +69,13 @@ public: WebView *currentTab() const; QAction *actionByName(const QString name); virtual QSize sizeHint() const; - + virtual KActionCollection *actionCollection () const; + private: void setupActions(); void setupHistoryMenu(); - void setupBars(); void setupTools(); + void setupToolbar(); void setupSidePanel(); SidePanel *sidePanel(); @@ -152,6 +155,8 @@ private: QString m_homePage; QPointer m_popup; + + KActionCollection *m_ac; }; #endif // MAINWINDOW_H diff --git a/src/rekonqui.rc b/src/rekonqui.rc deleted file mode 100644 index 6b250ab3..00000000 --- a/src/rekonqui.rc +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - -&File - - - - - - - - - - - - - - - -&Edit - - - - - - - - - - - - - -&View - - - - - - - - - - - - - - - -Hi&story - - - -&Bookmarks - - - -&Tools - - - - - - -&Settings - - - - - - - - - - - - - - - -Main Toolbar - - - - - - - - - - - - - - -- cgit v1.2.1