diff --git a/runtime/BrowserWindow.cpp b/runtime/BrowserWindow.cpp index f5645e735..5419c0e1c 100644 --- a/runtime/BrowserWindow.cpp +++ b/runtime/BrowserWindow.cpp @@ -45,9 +45,8 @@ BrowserWindow::BrowserWindow(QString url) m_appServerUrl = url; - // Setup the UI + // Setup the shortcuts createActions(); - createMenus(); m_tabWidget = new TabWindow(this); m_mainGridLayout = new QGridLayout(m_tabWidget); @@ -111,45 +110,24 @@ void BrowserWindow::closeEvent(QCloseEvent *event) void BrowserWindow::createActions() { // Open an arbitrary URL - openUrlAction = new QAction(tr("&Open URL..."), this); - openUrlAction->setShortcut(tr("Ctrl+U")); - openUrlAction->setStatusTip(tr("Open a URL")); - connect(openUrlAction, SIGNAL(triggered()), this, SLOT(openUrl())); + openUrlShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_U), this); + openUrlShortcut->setContext(Qt::ApplicationShortcut); + connect(openUrlShortcut, SIGNAL(activated()), this, SLOT(openUrl())); // Set the Python Path - configurationAction = new QAction(tr("&Configuration..."), this); - configurationAction->setStatusTip(tr("Configure the application paths")); - connect(configurationAction, SIGNAL(triggered()), this, SLOT(configuration())); + preferencesShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P), this); + preferencesShortcut->setContext(Qt::ApplicationShortcut); + connect(preferencesShortcut, SIGNAL(activated()), this, SLOT(preferences())); // Exit the app - exitAction = new QAction(tr("E&xit"), this); - exitAction->setStatusTip(tr("Exit the application")); - exitAction->setShortcuts(QKeySequence::Quit); - connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); + exitShortcut = new QShortcut(QKeySequence::Quit, this); + exitShortcut->setContext(Qt::ApplicationShortcut); + connect(exitShortcut, SIGNAL(activated()), this, SLOT(close())); // About box - aboutAction = new QAction(tr("&About"), this); - aboutAction->setStatusTip(tr("Show the application's About box")); - connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); -} - - -// Create the application menus -void BrowserWindow::createMenus() -{ - // File - fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(openUrlAction); - fileMenu->addSeparator(); - fileMenu->addAction(configurationAction); - fileMenu->addSeparator(); - fileMenu->addAction(exitAction); - - menuBar()->addSeparator(); - - // Help - helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(aboutAction); + aboutShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A), this); + aboutShortcut->setContext(Qt::ApplicationShortcut); + connect(aboutShortcut, SIGNAL(activated()), this, SLOT(about())); } @@ -465,7 +443,7 @@ void BrowserWindow::openUrl() } // Edit the app configuration -void BrowserWindow::configuration() +void BrowserWindow::preferences() { QSettings settings; bool ok; @@ -487,4 +465,3 @@ void BrowserWindow::configuration() } } - diff --git a/runtime/BrowserWindow.h b/runtime/BrowserWindow.h index 799a8327f..43f90fef3 100644 --- a/runtime/BrowserWindow.h +++ b/runtime/BrowserWindow.h @@ -47,7 +47,7 @@ protected slots: private slots: void openUrl(); - void configuration(); + void preferences(); void about(); public slots: @@ -58,12 +58,11 @@ public slots: private: QString m_appServerUrl; WebViewWindow *m_mainWebView; - QMenu *fileMenu; - QMenu *helpMenu; - QAction *openUrlAction; - QAction *configurationAction; - QAction *exitAction; - QAction *aboutAction; + + QShortcut *openUrlShortcut; + QShortcut *preferencesShortcut; + QShortcut *exitShortcut; + QShortcut *aboutShortcut; QGridLayout *m_tabGridLayout; QGridLayout *m_mainGridLayout; @@ -82,7 +81,6 @@ private: int m_loadAttempt; void createActions(); - void createMenus(); void pause(int seconds = 1); int findURLTab(const QUrl &name); };