HAL
file_modified_bar.cpp
Go to the documentation of this file.
2 #include "gui/gui_globals.h"
5 #include <QFileInfo>
6 #include <sys/types.h>
7 
8 namespace hal
9 {
11  {
12  Q_UNUSED(parent);
13  mLayout = new QHBoxLayout();
14  setLayout(mLayout);
15 
16  mMessageLabel = new QLabel("");
17  mLayout->addWidget(mMessageLabel);
18 
19  mReloadButton = new QPushButton("Reload");
21  mLayout->addWidget(mReloadButton);
22 
23  mIgnoreButton = new QPushButton("Ignore");
25  mLayout->addWidget(mIgnoreButton);
26 
27  mOkButton = new QPushButton("Ok");
29  mLayout->addWidget(mOkButton);
30 
31  mAbortButton = new QPushButton("Abort");
33  mLayout->addWidget(mAbortButton);
34 
35 
36  connect(mReloadButton, &QPushButton::clicked, this, &FileModifiedBar::handleReloadClicked);
37  connect(mIgnoreButton, &QPushButton::clicked, this, &FileModifiedBar::handleIgnoreClicked);
38  connect(mOkButton, &QPushButton::clicked, this, &FileModifiedBar::handleOkClicked);
39  connect(mAbortButton, &QPushButton::clicked, this, &FileModifiedBar::handleAbortClicked);
40  }
41 
43  {
44  QFile file(path);
45 
46  if(file.exists())
47  handleFileContentModified(path);
48  else
49  handleFileMovOrDel(path);
50  }
51 
53  {
54  mAbortButton->setHidden(false);
55  mOkButton->setHidden(true);
56  mReloadButton->setHidden(true);
57  mIgnoreButton->setHidden(true);
58 
59  mMessageLabel->setText("Executing script " + path + "...");
60  }
61 
62 
63  void FileModifiedBar::handleFileContentModified(QString path)
64  {
65  mAbortButton->setHidden(true);
66  mOkButton->setHidden(true);
67  mReloadButton->setHidden(false);
68  mIgnoreButton->setHidden(false);
69 
70  mMessageLabel->setText(path + " has been modified on disk.");
71  }
72 
73  void FileModifiedBar::handleFileMovOrDel(QString path)
74  {
75  mAbortButton->setHidden(true);
76  mOkButton->setHidden(false);
77  mReloadButton->setHidden(true);
78  mIgnoreButton->setHidden(true);
79 
80  mMessageLabel->setText(path + " has been moved on disk.");
81  }
82 
83  // FIXME why are we using FileModifiedBar for aborting a python script?
84  void FileModifiedBar::handleAbortClicked()
85  {
86  gPythonContext->abortThread();
87  }
88 
89 
90  void FileModifiedBar::handleReloadClicked()
91  {
93  }
94 
95  void FileModifiedBar::handleIgnoreClicked()
96  {
98  }
99 
100  void FileModifiedBar::handleOkClicked()
101  {
102  Q_EMIT okClicked();
103  }
104 }
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
void handleFileChanged(QString path)
void handleScriptExecute(QString path)
FileModifiedBar(QWidget *parent=nullptr)
PythonContext * gPythonContext
Definition: plugin_gui.cpp:88
void clicked(bool checked)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
void setText(const QString &)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
void setHidden(bool hidden)
void setLayout(QLayout *layout)
void setSizePolicy(QSizePolicy)