diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainview.cpp | 182 | ||||
-rw-r--r-- | src/mainview.h | 8 | ||||
-rw-r--r-- | src/mainwindow.cpp | 49 | ||||
-rw-r--r-- | src/mainwindow.h | 1 |
4 files changed, 120 insertions, 120 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp index 21c318ed..d796035e 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -35,6 +35,7 @@ #include <KShortcut> #include <KStandardShortcut> #include <KMessageBox> +#include <KActionCollection> // Qt Includes #include <QtGui> @@ -45,10 +46,6 @@ MainView::MainView(QWidget *parent) : KTabWidget(parent) , m_recentlyClosedTabsAction(0) - , m_newTabAction(0) - , m_closeTabAction(0) - , m_nextTabAction(0) - , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) , m_lineEdits(0) @@ -65,25 +62,7 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); setTabBar(m_tabBar); - // Actions - 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())); - - m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - m_closeTabAction->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); - m_closeTabAction->setIconVisibleInMenu(false); - connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); - - m_nextTabAction = new KAction(i18n("Show Next Tab"), this); - m_nextTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); - connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); - - m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); - m_previousTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); - connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); - + // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); @@ -91,19 +70,7 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); - // corner buttons - QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction(m_newTabAction); - addTabButton->setAutoRaise(true); - addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(addTabButton, Qt::TopLeftCorner); - - QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction(m_closeTabAction); - closeTabButton->setAutoRaise(true); - closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(closeTabButton, Qt::TopRightCorner); - + // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); @@ -117,85 +84,90 @@ MainView::~MainView() } -// ======================================================================================================== - KAction *MainView::newTabAction() const {return m_newTabAction; } - KAction *MainView::closeTabAction() const {return m_closeTabAction; } - KAction *MainView::recentlyClosedTabsAction() const {return m_recentlyClosedTabsAction;} - KAction *MainView::nextTabAction() const{} - KAction *MainView::previousTabAction() const{} +KAction *MainView::recentlyClosedTabsAction() const +{ + return m_recentlyClosedTabsAction; +} - void MainView::slotWebReload() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Reload); - action->trigger(); - } - void MainView::slotWebBack() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Back); - action->trigger(); - } +void MainView::slotWebReload() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Reload); + action->trigger(); +} - void MainView::slotWebForward() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Forward); - action->trigger(); - } - void MainView::slotWebUndo() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Undo); - action->trigger(); - } +void MainView::slotWebBack() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Back); + action->trigger(); +} - void MainView::slotWebRedo() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Redo); - action->trigger(); - } - void MainView::slotWebCut() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Cut); - action->trigger(); - } +void MainView::slotWebForward() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Forward); + action->trigger(); +} - void MainView::slotWebCopy() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Copy); - action->trigger(); - } - void MainView::slotWebPaste() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Paste); - action->trigger(); - } +void MainView::slotWebUndo() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Undo); + action->trigger(); +} - void MainView::slotWebSelectAll() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - // FIXME - } -// ======================================================================================================== +void MainView::slotWebRedo() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Redo); + action->trigger(); +} + + +void MainView::slotWebCut() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Cut); + action->trigger(); +} + + +void MainView::slotWebCopy() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Copy); + action->trigger(); +} + + +void MainView::slotWebPaste() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Paste); + action->trigger(); +} + + +void MainView::slotWebSelectAll() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + // FIXME +} void MainView::clear() diff --git a/src/mainview.h b/src/mainview.h index 9fdc24bd..fa5c805f 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -76,11 +76,7 @@ signals: public: void clear(); - KAction *newTabAction() const; - KAction *closeTabAction() const; KAction *recentlyClosedTabsAction() const; - KAction *nextTabAction() const; - KAction *previousTabAction() const; QWidget *lineEditStack() const; QLineEdit *currentLineEdit() const; @@ -131,10 +127,6 @@ private slots: private: KAction *m_recentlyClosedTabsAction; - KAction *m_newTabAction; - KAction *m_closeTabAction; - KAction *m_nextTabAction; - KAction *m_previousTabAction; KMenu *m_recentlyClosedTabsMenu; static const int m_recentlyClosedTabsSize = 10; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e14f8611..6fcdf7e6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -99,6 +99,9 @@ MainWindow::MainWindow() // setup history & bookmarks menus setupCustomMenu(); + // setup Tab Bar + setupTabBar(); + // setting up custom widgets.. KToolBar *navigationBar = toolBar( "mainToolBar" ); navigationBar->addWidget( m_tabWidget->lineEditStack() ); @@ -152,7 +155,7 @@ void MainWindow::setupActions() m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); - // Custom Actions + // ============== Custom Actions a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); actionCollection()->addAction( QLatin1String("stop"), a ); @@ -162,9 +165,6 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("open location"), a ); connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotOpenLocation() ) ); - actionCollection()->addAction( QLatin1String("new tab"), m_tabWidget->newTabAction() ); - actionCollection()->addAction( QLatin1String("close tab"), m_tabWidget->closeTabAction() ); - a = new KAction( i18n("Private &Browsing..."), this ); a->setCheckable(true); actionCollection()->addAction( i18n("private browsing"), a ); @@ -198,13 +198,13 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("web inspector"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotToggleInspector(bool) ) ); - // BOOKMARKS MENU + // ================== BOOKMARKS MENU a = new KActionMenu( i18n("B&ookmarks"), this ); actionCollection()->addAction( QLatin1String("bookmarks"), a ); BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); a->setMenu( bookmarksMenu ); - // history related actions + // ================ history related actions KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); historyBack->setMenu(m_historyBackMenu); @@ -217,9 +217,44 @@ void MainWindow::setupActions() connect(historyForward, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenNext() ) ); actionCollection()->addAction( QLatin1String("history forward"), historyForward ); - // =================================================================================================================== + // =================== Tab Actions + a = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); + a->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); + actionCollection()->addAction( QLatin1String("new tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(newTab())); + + a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); + a->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); + actionCollection()->addAction( QLatin1String("close tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(closeTab())); + + a = new KAction(i18n("Show Next Tab"), this); + a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); + actionCollection()->addAction( QLatin1String("show next tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(nextTab())); + a = new KAction(i18n("Show Previous Tab"), this); + a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); + actionCollection()->addAction( QLatin1String("show prev tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(previousTab())); +} + + +void MainWindow::setupTabBar() +{ + // Left corner button + QToolButton *addTabButton = new QToolButton(this); + addTabButton->setDefaultAction( actionCollection()->action("new tab") ); + addTabButton->setAutoRaise(true); + addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + m_tabWidget->setCornerWidget(addTabButton, Qt::TopLeftCorner); + // right corner button + QToolButton *closeTabButton = new QToolButton(this); + closeTabButton->setDefaultAction( actionCollection()->action("close tab") ); + closeTabButton->setAutoRaise(true); + closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + m_tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); } diff --git a/src/mainwindow.h b/src/mainwindow.h index e34c799e..fd7f13d6 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -62,6 +62,7 @@ public: private: void setupActions(); void setupCustomMenu(); + void setupTabBar(); public slots: void slotHome(); |