File indexing completed on 2024-04-21 16:33:19

0001 /*
0002     SPDX-FileCopyrightText: 2000 Shie Erlich <krusader@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2000 Rafi Yanai <krusader@users.sourceforge.net>
0004     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KRUSADERVIEW_H
0010 #define KRUSADERVIEW_H
0011 
0012 // QtCore
0013 #include <QEvent>
0014 // QtWidgets
0015 #include <QGridLayout>
0016 #include <QLayout>
0017 #include <QPushButton>
0018 #include <QSplitter>
0019 #include <QWidget>
0020 
0021 #include "krglobal.h"
0022 
0023 class PanelManager;
0024 class ListPanel;
0025 class KFnKeys;
0026 class KCMDLine;
0027 class TerminalDock;
0028 
0029 class KrusaderView : public QWidget
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     explicit KrusaderView(QWidget *parent = nullptr);
0035     ~KrusaderView() override = default;
0036     void start(const KConfigGroup &cfg, bool restoreSettings, const QList<QUrl> &leftTabs, const QList<QUrl> &rightTabs);
0037     void updateGUI(const KConfigGroup &cfg);
0038     void saveSettings(KConfigGroup &cfg);
0039     void cmdLineFocus(); // command line receives keyboard focus
0040     void cmdLineUnFocus(); // return focus from command line to active panel
0041 
0042     bool isLeftActive() const
0043     {
0044         return leftMng == activeMng;
0045     }
0046 
0047     // used by krGlobal macros
0048     PanelManager *activeManager() const
0049     {
0050         return activeMng;
0051     }
0052     PanelManager *inactiveManager() const
0053     {
0054         return activeMng == leftMng ? rightMng : leftMng;
0055     }
0056     PanelManager *leftManager() const
0057     {
0058         return leftMng;
0059     }
0060     PanelManager *rightManager() const
0061     {
0062         return rightMng;
0063     }
0064     KrPanel *activePanel() const;
0065     ListPanel *leftPanel() const;
0066     ListPanel *rightPanel() const;
0067 
0068     KFnKeys *fnKeys() const
0069     {
0070         return _fnKeys;
0071     }
0072     KCMDLine *cmdLine() const
0073     {
0074         return _cmdLine;
0075     }
0076     TerminalDock *terminalDock() const
0077     {
0078         return _terminalDock;
0079     }
0080     bool isVertical() const
0081     {
0082         return horiz_splitter != nullptr ? horiz_splitter->orientation() == Qt::Vertical : false;
0083     }
0084     void swapSides();
0085     void setPanelSize(bool leftPanel, int percent);
0086     bool isTerminalEmulatorFullscreen();
0087 
0088 public slots:
0089     void slotSetActiveManager(PanelManager *manager);
0090     void slotPathChanged(ListPanel *listPanel);
0091     // Tab - switch focus
0092     void panelSwitch();
0093     void toggleVerticalMode();
0094 
0095     void setTerminalEmulator(bool show, bool fullscreen = false);
0096     void focusTerminalEmulator();
0097     void toggleFullScreenTerminalEmulator();
0098 
0099     void focusUp();
0100     void focusDown();
0101 
0102     void profiles(const QString &profileName = QString());
0103     void loadPanelProfiles(const QString &group);
0104     void savePanelProfiles(const QString &group);
0105 
0106     void draggingTab(PanelManager *from, QMouseEvent *e);
0107     void draggingTabFinished(PanelManager *from, QMouseEvent *e);
0108 
0109 private:
0110     int getFocusCandidates(QVector<QWidget *> &widgets);
0111     bool cursorIsOnOtherSide(PanelManager *of, const QPoint &globalPos);
0112     PanelManager *createManager(bool left);
0113     void updateCurrentActivePath();
0114 
0115     KFnKeys *_fnKeys; // function keys
0116     KCMDLine *_cmdLine; // command line widget
0117     TerminalDock *_terminalDock; // docking widget for terminal emulator
0118     QSplitter *horiz_splitter, *vert_splitter;
0119     QList<int> verticalSplitterSizes;
0120     PanelManager *activeMng, *leftMng, *rightMng; // saving them for panel swaps
0121     QGridLayout *mainLayout, *terminal_layout;
0122 };
0123 
0124 #endif