347 lines
7.5 KiB
C++
Executable File
347 lines
7.5 KiB
C++
Executable File
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "lts_base.h"
|
|
#include "lts_widgets_export.h"
|
|
#include "lts_notification_box.h"
|
|
#include "qevent.h"
|
|
|
|
#include <memory>
|
|
#include <QMap>
|
|
#include <QPointer>
|
|
#include <QWidget>
|
|
|
|
|
|
class QButtonGroup;
|
|
class QPropertyAnimation;
|
|
class QPushButton;
|
|
class QTimer;
|
|
class QToolButton;
|
|
|
|
namespace Ui
|
|
{
|
|
class LtsBaseLayoutWidget;
|
|
}
|
|
|
|
namespace IDL
|
|
{
|
|
enum class PartitionType;
|
|
}
|
|
|
|
namespace LtsUtils { class Promise; }
|
|
|
|
namespace LtsWidgets
|
|
{
|
|
class LtsDragIcon;
|
|
class LtsProgressDialogHelper;
|
|
class LtsTabWidget;
|
|
class LtsToolBarArea;
|
|
class LtsToolBox;
|
|
|
|
struct ExerciseData
|
|
{
|
|
QString exName;
|
|
QString exDescription;
|
|
int phId = -1;
|
|
QString phName;
|
|
QString phDescription;
|
|
QString exStateString;
|
|
ExcState exState = ExerciseState::eUnknown;
|
|
QColor exStateCol;
|
|
QString partitionType;
|
|
|
|
bool operator==(const ExerciseData &o) const
|
|
{
|
|
return exName == o.exName &&
|
|
exDescription == o.exDescription &&
|
|
phId == o.phId &&
|
|
phName == o.phName &&
|
|
phDescription == o.phDescription &&
|
|
exStateString == o.exStateString &&
|
|
exState == o.exState &&
|
|
exStateCol == o.exStateCol &&
|
|
partitionType == o.partitionType;
|
|
}
|
|
bool operator!=(const ExerciseData &o) const
|
|
{
|
|
return !operator ==(o);
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class LTSWIDGETS_EXPORT LtsBaseLayoutWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit LtsBaseLayoutWidget(QWidget *parent = nullptr, bool splitMenu = true);
|
|
~LtsBaseLayoutWidget();
|
|
|
|
|
|
|
|
void hideVisibleLayouts();
|
|
|
|
|
|
|
|
void resetLayoutVisibility();
|
|
|
|
|
|
|
|
void setMenuVisible(bool visible);
|
|
|
|
|
|
|
|
bool isMenuVisible() const;
|
|
|
|
bool isTopBarVisible() const;
|
|
void setTopBarVisible(bool visible);
|
|
|
|
|
|
|
|
bool isMenuCollapsed() const;
|
|
|
|
|
|
|
|
void collapseMenu(bool collapse = true);
|
|
|
|
|
|
|
|
void setSessionInfo(const int domainId, const IDL::PartitionType &partitionType, const int partitionId, const QString &workspaceId);
|
|
|
|
|
|
|
|
LtsDragIcon *addMenuAction(const PluginData &plData, bool isFirstRun = false);
|
|
|
|
|
|
|
|
bool removeMenuAction(const PluginData &plData);
|
|
|
|
|
|
|
|
bool removeMenuAction(LtsDragIcon *icon);
|
|
|
|
bool removeMenuAction(const QString &byIdentifier);
|
|
|
|
|
|
|
|
void clearMenuActions();
|
|
|
|
void setAppName(const QString &appName);
|
|
bool isDialogFocused(const LtsDialog *dialog) const;
|
|
|
|
|
|
|
|
void setCustomText(const QString &text);
|
|
const QString customText() const;
|
|
|
|
|
|
|
|
LtsTabWidget *getTabFromLayoutArea(LayoutArea area) const;
|
|
|
|
|
|
|
|
LtsDialog *getWidget(const QString &menuGroup, const QString &identifier, LayoutArea area = LayoutArea::eUnknown);
|
|
|
|
|
|
|
|
QWidget *getMenu() const;
|
|
|
|
|
|
|
|
LtsToolBarArea *getToolbar() const;
|
|
|
|
|
|
|
|
void setOperatorName(const QString &operatorName, bool showTerminalButton);
|
|
|
|
|
|
|
|
void setProfilePicture(const QPixmap &profilePicture);
|
|
|
|
|
|
|
|
void setExerciseData(const ExerciseData &data);
|
|
|
|
|
|
|
|
void initilizationFinished();
|
|
|
|
|
|
|
|
void addNotification(QToolButton *noti);
|
|
|
|
|
|
|
|
bool isWidgetsHidden() const;
|
|
|
|
bool notificationExists(const QString &identifier) const;
|
|
const QMap<LtsDragIcon *, PluginData> &mapButtons() const { return m_mapButtons; }
|
|
void setToolBarActions(const QStringList &actions);
|
|
QStringList toolBarActions() const;
|
|
void setFunctionKeys(const QMap<int, QString> &actions);
|
|
QMap<int, QString> functionKeys() const;
|
|
void setWorkspaceId(const QString &workspaceId) { m_workspaceId = workspaceId; }
|
|
|
|
|
|
|
|
void showMessage(const QString &title, const QString &text, LtsNotificationBox::MessageType type = LtsNotificationBox::MessageType::Info, const std::function<void(const QString &link)> &clickedLinkCallback = nullptr, bool closeOnLinkClicked = true, const QString &identifier = {});
|
|
bool messageIdentifierExists(const QString &identifier) const;
|
|
|
|
void executeAction(const QString &actionIdentifier);
|
|
bool isSecondaryWidget() const { return m_isSecondaryWidget; }
|
|
void setSecondaryWidget() { m_isSecondaryWidget = true; }
|
|
|
|
|
|
|
|
void removeQueuedMessage(const QString &messageIdentifier);
|
|
|
|
|
|
public slots:
|
|
bool slotClose();
|
|
void slotLogout();
|
|
|
|
void slotScreenCountChanged(int count);
|
|
|
|
|
|
|
|
void onMenuEntryClicked();
|
|
|
|
void onHideAnimated();
|
|
void onReShowAnimated();
|
|
|
|
|
|
|
|
bool addWidget(LtsWidgets::LtsDialog *dialog, const QString &menuGroup, const QString &identifier, LtsWidgets::LayoutArea area = LayoutArea::eUnknown, bool setClosable = true, bool focusNewTab = true);
|
|
|
|
|
|
|
|
bool addOrReplaceWidget(LtsDialog *dialog, const QString &menuGroup, const QString &identifier, LayoutArea area = LayoutArea::eUnknown, bool setClosable = true, bool focusNewTab = true );
|
|
|
|
bool focusTab(const QString &menuGroup, const QString &identifier, LtsWidgets::LayoutArea area);
|
|
|
|
|
|
|
|
void executeCreateInstantFunctions(const LtsWidgets::PluginData &plData);
|
|
|
|
void setExerciseTime(qint64 mSecsSinceEpoch);
|
|
bool haveUnsavedChanges();
|
|
|
|
|
|
|
|
|
|
|
|
bool notifyUnsavedChanges();
|
|
|
|
|
|
|
|
void setIrreplaceableOnce() { m_irreplaceableOnce = true; }
|
|
bool irreplaceableReset() { bool r = m_irreplaceableOnce; m_irreplaceableOnce = false; return r; }
|
|
bool isIrreplaceable() const { return m_irreplaceableOnce; }
|
|
|
|
|
|
|
|
void showWidgets();
|
|
|
|
|
|
|
|
void hideWidgets();
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
void slotOperatorMenuClicked();
|
|
|
|
void setCurrentTime();
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
|
|
void signalClose();
|
|
void signalLogout();
|
|
void signalShowOperatorSettings();
|
|
void signalRetranslateActions();
|
|
void signalSwap();
|
|
void signalStapleTopicLockHandler(LtsWidgets::LtsDialog *widget);
|
|
void signalSuccessfullyPlaced();
|
|
|
|
|
|
|
|
void signalNotifyUnsavedChanges(bool &reject);
|
|
|
|
protected:
|
|
|
|
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
void showEvent(QShowEvent *event) override;
|
|
void changeEvent(QEvent *e) override;
|
|
|
|
|
|
private:
|
|
void addDebugMenu();
|
|
void retranslate();
|
|
void addTouchScroll(QWidget *widget);
|
|
LtsDragIcon *createButton(const PluginData &plData);
|
|
int getIndexOfTab(LtsTabWidget *tab);
|
|
LtsToolBox *getToolBox(const ExercisePart &exercisePart) const;
|
|
QPushButton *getExercisePartButton(const ExercisePart &exercisePart) const;
|
|
void checkExercisePartButtonVisibility();
|
|
void checkMenuGroup(const QString &menuGroup, const ExercisePart &exercisePart);
|
|
bool isDialogFocused(const LtsDialog *dialog, const LayoutArea &layoutArea) const;
|
|
bool isDialogFocused(const LtsDialog *dialog, const LtsTabWidget *tab) const;
|
|
void applyExerciseStateRestricition();
|
|
void executePluginData(const PluginData &plData);
|
|
void showNextQueuedMessage();
|
|
|
|
|
|
struct Message
|
|
{
|
|
public:
|
|
QString title;
|
|
QString text;
|
|
LtsNotificationBox::MessageType type;
|
|
std::function<void(const QString &link)> clickedLinkCallback;
|
|
bool closeOnLinkClicked;
|
|
QString identifier;
|
|
};
|
|
|
|
ExerciseData m_exerciseData;
|
|
QMap<LtsDragIcon *, PluginData> m_mapButtons;
|
|
QList<int> m_mainSplitterSizes;
|
|
QList<int> m_menuSplitterSizes;
|
|
bool m_isHidden;
|
|
QPropertyAnimation *m_currentAnimation{nullptr};
|
|
Ui::LtsBaseLayoutWidget *m_ui{nullptr};
|
|
IDL::PartitionType m_partitionType;
|
|
int m_domainId;
|
|
int m_partitionId;
|
|
QString m_operatorName;
|
|
bool m_firstShow;
|
|
bool m_showTerminalButton;
|
|
qint64 m_exerciseTime;
|
|
QTimer *m_setCurrentTimeTimer{nullptr};
|
|
bool m_irreplaceableOnce;
|
|
QButtonGroup *m_bg{nullptr};
|
|
QString m_workspaceId;
|
|
int m_screenCount;
|
|
bool m_menuCollapsed;
|
|
QMap<QPointer<LtsWidgets::LtsTabWidget>, bool> m_oldLayoutVisibilityStates;
|
|
LtsNotificationBox *m_notiBox{nullptr};
|
|
QStringList m_notFoundYet;
|
|
bool m_isSecondaryWidget { false };
|
|
QVector<Message> m_currentMessage;
|
|
QVector<Message> m_messageQueue;
|
|
};
|
|
|
|
}
|