2022-03-14 17:56:18 +01:00
|
|
|
/*
|
2024-03-29 10:09:48 +01:00
|
|
|
Copyright 2006-2024 The QElectroTech Team
|
2022-03-14 17:56:18 +01:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef TERMINALSTRIPEDITORWINDOW_H
|
|
|
|
#define TERMINALSTRIPEDITORWINDOW_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
2022-12-02 18:12:47 +01:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QPointer>
|
2022-03-14 17:56:18 +01:00
|
|
|
|
|
|
|
class QETProject;
|
|
|
|
class TerminalStripTreeDockWidget;
|
2022-03-16 18:58:36 +01:00
|
|
|
class TerminalStrip;
|
2022-03-16 22:44:08 +01:00
|
|
|
class FreeTerminalEditor;
|
2022-03-20 18:25:25 +01:00
|
|
|
class TerminalStripEditor;
|
2022-03-23 21:18:22 +01:00
|
|
|
class QAbstractButton;
|
2022-03-14 17:56:18 +01:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class TerminalStripEditorWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
class TerminalStripEditorWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2022-12-02 18:12:47 +01:00
|
|
|
private:
|
|
|
|
//We need to use a QPointer instead of a raw pointer because when window_
|
|
|
|
//have got a parent widget, the parent widget can delete the window_
|
|
|
|
//instance in her destrucor and then window_ become a dangling pointer.
|
|
|
|
static QPointer<TerminalStripEditorWindow> window_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr) {
|
|
|
|
static QMutex mutex_;
|
|
|
|
if (!window_) {
|
|
|
|
mutex_.lock();
|
|
|
|
if (!window_)
|
|
|
|
window_ = new TerminalStripEditorWindow{project, parent};
|
|
|
|
mutex_.unlock();
|
|
|
|
}
|
|
|
|
return window_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dropInstance () {
|
|
|
|
static QMutex mutex;
|
|
|
|
if (window_) {
|
|
|
|
mutex.lock();
|
|
|
|
window_->deleteLater();
|
|
|
|
window_.clear();
|
|
|
|
mutex.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void edit(TerminalStrip *strip);
|
|
|
|
|
|
|
|
public:
|
2022-03-14 17:56:18 +01:00
|
|
|
explicit TerminalStripEditorWindow(QETProject *project, QWidget *parent = nullptr);
|
|
|
|
~TerminalStripEditorWindow();
|
|
|
|
|
2022-12-02 18:12:47 +01:00
|
|
|
void setCurrentStrip(TerminalStrip *strip);
|
|
|
|
|
2022-03-16 18:58:36 +01:00
|
|
|
private slots:
|
|
|
|
void on_m_add_terminal_strip_triggered();
|
|
|
|
void on_m_remove_terminal_triggered();
|
|
|
|
void on_m_reload_triggered();
|
2022-03-23 21:18:22 +01:00
|
|
|
void on_m_button_box_clicked(QAbstractButton *button);
|
2022-03-25 19:00:09 +01:00
|
|
|
void on_m_stacked_widget_currentChanged(int arg1);
|
|
|
|
|
2022-03-14 17:56:18 +01:00
|
|
|
private:
|
|
|
|
void addTreeDockWidget();
|
2022-03-16 18:58:36 +01:00
|
|
|
void currentStripChanged(TerminalStrip *strip);
|
2022-03-16 22:44:08 +01:00
|
|
|
void updateUi();
|
2022-03-14 17:56:18 +01:00
|
|
|
|
|
|
|
private:
|
2022-03-20 18:25:25 +01:00
|
|
|
Ui::TerminalStripEditorWindow *ui{nullptr};
|
2022-03-16 22:44:08 +01:00
|
|
|
QETProject *m_project {nullptr};
|
2022-03-20 18:25:25 +01:00
|
|
|
TerminalStripTreeDockWidget *m_tree_dock{nullptr};
|
2022-03-16 22:44:08 +01:00
|
|
|
FreeTerminalEditor *m_free_terminal_editor {nullptr};
|
2022-03-20 18:25:25 +01:00
|
|
|
TerminalStripEditor *m_terminal_strip_editor {nullptr};
|
2022-03-14 17:56:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TERMINALSTRIPEDITORWINDOW_H
|