Commit cc49bd1f authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add fullscreen support

parent 57a03267
Pipeline #154201 failed with stage
in 1 minute and 15 seconds
<!DOCTYPE gui>
<gui name="kaddressbook" version="43" translationDomain="kaddressbook">
<gui name="kaddressbook" version="44" translationDomain="kaddressbook">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
......@@ -46,6 +46,8 @@
<Action name="view_mode_3columns"/>
<Separator/>
<Action name="options_show_qrcodes"/>
<Separator/>
<Action name="fullscreen"/>
</Menu>
<Menu name="action" noMerge="1"><text>&amp;Action</text>
......
......@@ -17,6 +17,7 @@
#include <KSharedConfig>
#include <KShortcutsDialog>
#include <KStandardAction>
#include <KToggleFullScreenAction>
#include <KToolBar>
#include <QAction>
#include <QMenuBar>
......@@ -25,6 +26,7 @@
#include "userfeedback/userfeedbackmanager.h"
#include <KUserFeedback/NotificationPopup>
#include <KUserFeedback/Provider>
#include <QFontDatabase>
#endif
MainWindow::MainWindow()
......@@ -80,6 +82,29 @@ void MainWindow::initActions()
disconnect(mHamburgerMenu, &KHamburgerMenu::aboutToShowMenu, this, nullptr);
});
}
mShowFullScreenAction = KStandardAction::fullScreen(nullptr, nullptr, this, actionCollection());
actionCollection()->setDefaultShortcut(mShowFullScreenAction, Qt::Key_F11);
connect(mShowFullScreenAction, &QAction::toggled, this, &MainWindow::slotFullScreen);
}
void MainWindow::slotFullScreen(bool t)
{
KToggleFullScreenAction::setFullScreen(this, t);
QMenuBar *mb = menuBar();
if (t) {
auto b = new QToolButton(mb);
b->setDefaultAction(mShowFullScreenAction);
b->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
b->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
mb->setCornerWidget(b, Qt::TopRightCorner);
b->setVisible(true);
b->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
} else {
QWidget *w = mb->cornerWidget(Qt::TopRightCorner);
if (w) {
w->deleteLater();
}
}
}
void MainWindow::updateHamburgerMenu()
......
......@@ -13,6 +13,7 @@
class MainWidget;
class KToggleAction;
class KHamburgerMenu;
class KToggleFullScreenAction;
class MainWindow : public KXmlGuiWindow
{
Q_OBJECT
......@@ -32,8 +33,10 @@ private:
void initActions();
void updateHamburgerMenu();
void slotFullScreen(bool t);
MainWidget *const mMainWidget;
KToggleAction *mShowMenuBarAction = nullptr;
KHamburgerMenu *mHamburgerMenu = nullptr;
KToggleFullScreenAction *mShowFullScreenAction = nullptr;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment