diff --git a/src/lib/app/commandlineoptions.cpp b/src/lib/app/commandlineoptions.cpp index bdfddec2c..061b8cf3b 100644 --- a/src/lib/app/commandlineoptions.cpp +++ b/src/lib/app/commandlineoptions.cpp @@ -51,7 +51,8 @@ void CommandLineOptions::showHelp() " -nw or --new-window open new window\n" " -pb or --private-browsing start private browsing\n" " -dm or --download-manager show download manager\n" - " -nr or --no-remote open new instance\n" + " -fs or --fullscreen toggle fullscreen\n" + " -nr or --no-remote open new browser instance\n" " -ct=URL or --current-tab=URL open URL in current tab\n" " -ow=URL or --open-window=URL open URL in new window\n" "\n" @@ -156,6 +157,12 @@ void CommandLineOptions::parseActions() m_actions.append(pair); } + if (arg.startsWith(QLatin1String("-fs")) || arg.startsWith(QLatin1String("--fullscreen"))) { + ActionPair pair; + pair.action = Qz::CL_ToggleFullScreen; + m_actions.append(pair); + } + if (arg.startsWith(QLatin1String("-ct")) || arg.startsWith(QLatin1String("--current-tab"))) { int index = arg.indexOf(QLatin1Char('=')); if (index != -1) { diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 0b54ba084..d4f705c23 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -170,6 +170,10 @@ MainApplication::MainApplication(int &argc, char** argv) case Qz::CL_NewWindow: messages.append(QLatin1String("ACTION:NewWindow")); break; + case Qz::CL_ToggleFullScreen: + messages.append(QLatin1String("ACTION:ToggleFullScreen")); + m_postLaunchActions.append(ToggleFullScreen); + break; case Qz::CL_ShowDownloadManager: messages.append(QLatin1String("ACTION:ShowDownloadManager")); m_postLaunchActions.append(OpenDownloadManager); @@ -320,6 +324,10 @@ void MainApplication::postLaunch() getWindow()->tabWidget()->addView(QUrl(), Qz::NT_SelectedNewEmptyTab); } + if (m_postLaunchActions.contains(ToggleFullScreen)) { + getWindow()->toggleFullScreen(); + } + AutoSaver* saver = new AutoSaver(); connect(saver, SIGNAL(saveApp()), this, SLOT(saveStateSlot())); @@ -560,6 +568,10 @@ void MainApplication::receiveAppMessage(QString message) downManager()->show(); actWin = downManager(); } + else if (text == QLatin1String("ToggleFullScreen") && actWin) { + QupZilla* qz = static_cast(actWin); + qz->toggleFullScreen(); + } else if (text.startsWith(QLatin1String("OpenUrlInCurrentTab"))) { actUrl = QUrl::fromUserInput(text.mid(19)); } @@ -577,13 +589,13 @@ void MainApplication::receiveAppMessage(QString message) return; } - QupZilla* qz = qobject_cast(actWin); - actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); actWin->raise(); actWin->activateWindow(); actWin->setFocus(); + QupZilla* qz = qobject_cast(actWin); + if (qz && !actUrl.isEmpty()) { qz->loadAddress(actUrl); } diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index a2956442f..c9d9ced8b 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -159,7 +159,7 @@ private slots: void saveSettings(); private: - enum PostLaunchAction { OpenDownloadManager, OpenNewTab }; + enum PostLaunchAction { OpenDownloadManager, OpenNewTab, ToggleFullScreen }; void loadTheme(const QString &name); void translateApp(); diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 69b5b476c..972ffe8ee 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -485,7 +485,7 @@ void QupZilla::setupMenu() #else m_actionShowFullScreen->setShortcut(QKeySequence("Ctrl+F11")); #endif - connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(toggleFullScreen(bool))); + connect(m_actionShowFullScreen, SIGNAL(triggered(bool)), MENU_RECEIVER, SLOT(toggleFullScreen())); m_actionStop = new QAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), MENU_RECEIVER); connect(m_actionStop, SIGNAL(triggered()), MENU_RECEIVER, SLOT(stop())); m_actionStop->setShortcut(QKeySequence("Esc")); @@ -1930,13 +1930,13 @@ bool QupZilla::event(QEvent* event) return QMainWindow::event(event); } -void QupZilla::toggleFullScreen(bool make) +void QupZilla::toggleFullScreen() { - if (make) { - showFullScreen(); + if (isFullScreen()) { + showNormal(); } else { - showNormal(); + showFullScreen(); } } diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index ab582ce8b..f9a8c8641 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -122,6 +122,7 @@ signals: public slots: void setWindowTitle(const QString &t); + void toggleFullScreen(); void showWebInspector(bool toggle = true); void showBookmarksToolbar(); @@ -200,7 +201,6 @@ private slots: void zoomIn(); void zoomOut(); void zoomReset(); - void toggleFullScreen(bool make); void changeEncoding(QObject* obj = 0); void triggerCaretBrowsing(); diff --git a/src/lib/app/qz_namespace.h b/src/lib/app/qz_namespace.h index 38dfea7a8..21a4b47c9 100644 --- a/src/lib/app/qz_namespace.h +++ b/src/lib/app/qz_namespace.h @@ -68,6 +68,7 @@ enum CommandLineAction { CL_NewTab, CL_NewWindow, CL_ShowDownloadManager, + CL_ToggleFullScreen, CL_StartPrivateBrowsing, CL_StartNewInstance, CL_ExitAction diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index c28159082..de9324d3c 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -183,7 +183,7 @@ NavigationBar::NavigationBar(QupZilla* mainClass) connect(m_buttonHome, SIGNAL(controlClicked()), p_QupZilla, SLOT(goHomeInNewTab())); connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab())); connect(m_buttonAddTab, SIGNAL(middleMouseClicked()), p_QupZilla->tabWidget(), SLOT(addTabFromClipboard())); - connect(m_exitFullscreen, SIGNAL(clicked(bool)), p_QupZilla, SLOT(toggleFullScreen(bool))); + connect(m_exitFullscreen, SIGNAL(clicked(bool)), p_QupZilla, SLOT(toggleFullScreen())); } void NavigationBar::setSplitterSizes(int locationBar, int websearchBar)