File indexing completed on 2024-04-28 05:11:02

0001 /*
0002     This file is part of Akregator.
0003 
0004     SPDX-FileCopyrightText: 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0007 */
0008 
0009 #pragma once
0010 
0011 #include "kparts/mainwindow.h"
0012 
0013 #include <QPointer>
0014 
0015 class KSqueezedTextLabel;
0016 class KHamburgerMenu;
0017 class KToggleAction;
0018 class KToggleFullScreenAction;
0019 class QTimer;
0020 namespace Akregator
0021 {
0022 class Part;
0023 class MainWindow;
0024 
0025 /**
0026  * This is the application "Shell".  It has a menubar, toolbar, and
0027  * statusbar but relies on the "Part" to do all the real work.
0028  *
0029  * @short Application Shell
0030  */
0031 class MainWindow : public KParts::MainWindow
0032 {
0033     Q_OBJECT
0034 public:
0035     explicit MainWindow(QWidget *parent = nullptr);
0036     ~MainWindow() override;
0037 
0038     /**
0039      * Creates the progress widget in the status bar and the ProgressDialog
0040      * and connects them.
0041      */
0042     void setupProgressWidgets();
0043 
0044     /**
0045      Loads the part
0046      @return Whether the part has been successfully created or not.
0047      */
0048     bool loadPart();
0049 
0050 public Q_SLOTS:
0051     void slotClearStatusText();
0052     void slotSetStatusBarText(const QString &c) override;
0053 
0054 protected:
0055     /**
0056      * This method is called when it is time for the app to save its
0057      * properties for session management purposes.
0058      */
0059     void saveProperties(KConfigGroup &) override;
0060 
0061     /**
0062      * This method is called when this app is restored.  The KConfig
0063      * object points to the session management config file that was saved
0064      * with @ref saveProperties
0065      */
0066     void readProperties(const KConfigGroup &) override;
0067 
0068     /**
0069      * Reimplemented to say if app will be running in system tray if necessary
0070      */
0071     bool queryClose() override;
0072 
0073 protected Q_SLOTS:
0074     void slotQuit();
0075 
0076 private Q_SLOTS:
0077 
0078     void optionsConfigureKeys();
0079     void optionsConfigureToolbars();
0080     void applyNewToolbarConfig();
0081     void slotOnShutdown();
0082     void updateStatusbarProgressVisibility();
0083 
0084 private:
0085     void updateHamburgerMenu();
0086     void slotToggleMenubar(bool dontShowWarning);
0087     void slotFullScreen(bool t);
0088     QPointer<Akregator::Part> m_part;
0089     KSqueezedTextLabel *const m_statusLabel;
0090     QWidget *m_statusbarProgress = nullptr;
0091     QTimer *m_hideProgressTimer = nullptr;
0092     KHamburgerMenu *mHamburgerMenu = nullptr;
0093     KToggleAction *mShowMenuBarAction = nullptr;
0094     KToggleFullScreenAction *mShowFullScreenAction = nullptr;
0095 };
0096 } // namespace Akregator