Skip to content

Commit

Permalink
Gui: [skip-ci] rename Sequencer to SequencerBar
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 25, 2020
1 parent f7d0329 commit 5c17f71
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Gui/MainWindow.cpp
Expand Up @@ -326,7 +326,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
d->sizeLabel = new QLabel(tr("Dimension"), statusBar());
d->sizeLabel->setMinimumWidth(120);
statusBar()->addWidget(d->actionLabel, 1);
QProgressBar* progressBar = Gui::Sequencer::instance()->getProgressBar(statusBar());
QProgressBar* progressBar = Gui::SequencerBar::instance()->getProgressBar(statusBar());
statusBar()->addPermanentWidget(progressBar, 0);
statusBar()->addPermanentWidget(d->sizeLabel, 0);

Expand Down
45 changes: 23 additions & 22 deletions src/Gui/ProgressBar.cpp
Expand Up @@ -42,7 +42,7 @@ using namespace Gui;


namespace Gui {
struct SequencerPrivate
struct SequencerBarPrivate
{
ProgressBar* bar;
WaitCursor* waitCursor;
Expand Down Expand Up @@ -74,33 +74,33 @@ struct ProgressBarPrivate
};
}

Sequencer* Sequencer::_pclSingleton = 0;
SequencerBar* SequencerBar::_pclSingleton = 0;

Sequencer* Sequencer::instance()
SequencerBar* SequencerBar::instance()
{
// not initialized?
if (!_pclSingleton)
{
_pclSingleton = new Sequencer();
_pclSingleton = new SequencerBar();
}

return _pclSingleton;
}

Sequencer::Sequencer ()
SequencerBar::SequencerBar()
{
d = new SequencerPrivate;
d = new SequencerBarPrivate;
d->bar = 0;
d->waitCursor = 0;
d->guiThread = true;
}

Sequencer::~Sequencer ()
SequencerBar::~SequencerBar()
{
delete d;
}

void Sequencer::pause()
void SequencerBar::pause()
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand All @@ -113,7 +113,7 @@ void Sequencer::pause()
QApplication::setOverrideCursor(Qt::ArrowCursor);
}

void Sequencer::resume()
void SequencerBar::resume()
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand All @@ -126,7 +126,7 @@ void Sequencer::resume()
d->bar->enterControlEvents(); // grab again
}

void Sequencer::startStep()
void SequencerBar::startStep()
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand All @@ -150,8 +150,9 @@ void Sequencer::startStep()
}
}

void Sequencer::checkAbort() {
if(d->bar->thread() != QThread::currentThread())
void SequencerBar::checkAbort()
{
if (d->bar->thread() != QThread::currentThread())
return;
if (!wasCanceled()) {
if(d->checkAbortTime.elapsed() < 500)
Expand All @@ -174,7 +175,7 @@ void Sequencer::checkAbort() {
}
}

void Sequencer::nextStep(bool canAbort)
void SequencerBar::nextStep(bool canAbort)
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand Down Expand Up @@ -203,13 +204,13 @@ void Sequencer::nextStep(bool canAbort)
}
}

void Sequencer::setProgress(size_t step)
void SequencerBar::setProgress(size_t step)
{
d->bar->show();
setValue((int)step);
}

void Sequencer::setValue(int step)
void SequencerBar::setValue(int step)
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand Down Expand Up @@ -251,7 +252,7 @@ void Sequencer::setValue(int step)
}
}

void Sequencer::showRemainingTime()
void SequencerBar::showRemainingTime()
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand Down Expand Up @@ -285,7 +286,7 @@ void Sequencer::showRemainingTime()
}
}

void Sequencer::resetData()
void SequencerBar::resetData()
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand Down Expand Up @@ -318,15 +319,15 @@ void Sequencer::resetData()
SequencerBase::resetData();
}

void Sequencer::abort()
void SequencerBar::abort()
{
//resets
resetData();
Base::AbortException exc("User aborted");
throw exc;
}

void Sequencer::setText (const char* pszTxt)
void SequencerBar::setText (const char* pszTxt)
{
QThread *currentThread = QThread::currentThread();
QThread *thr = d->bar->thread(); // this is the main thread
Expand All @@ -344,12 +345,12 @@ void Sequencer::setText (const char* pszTxt)
}
}

bool Sequencer::isBlocking() const
bool SequencerBar::isBlocking() const
{
return d->guiThread;
}

QProgressBar* Sequencer::getProgressBar(QWidget* parent)
QProgressBar* SequencerBar::getProgressBar(QWidget* parent)
{
if (!d->bar)
d->bar = new ProgressBar(this, parent);
Expand All @@ -360,7 +361,7 @@ QProgressBar* Sequencer::getProgressBar(QWidget* parent)

/* TRANSLATOR Gui::ProgressBar */

ProgressBar::ProgressBar (Sequencer* s, QWidget * parent)
ProgressBar::ProgressBar (SequencerBar* s, QWidget * parent)
: QProgressBar(parent), sequencer(s)
{
#ifdef QT_WINEXTRAS_LIB
Expand Down
22 changes: 11 additions & 11 deletions src/Gui/ProgressBar.h
Expand Up @@ -35,7 +35,7 @@

namespace Gui {

struct SequencerPrivate;
struct SequencerBarPrivate;
struct ProgressBarPrivate;
class ProgressBar;

Expand Down Expand Up @@ -90,11 +90,11 @@ class ProgressBar;
* just a busy indicator instead of percentage steps.
* @author Werner Mayer
*/
class GuiExport Sequencer : public Base::SequencerBase
class GuiExport SequencerBar : public Base::SequencerBase
{
public:
/** Returns the sequencer object. */
static Sequencer* instance();
static SequencerBar* instance();
/** This restores the last overridden cursor and release the keyboard while the progress bar
* is running. This is useful e.g. if a modal dialog appears while a long operation is performed
* to indicate that the user can click on the dialog. Every pause() must eventually be followed
Expand All @@ -111,9 +111,9 @@ class GuiExport Sequencer : public Base::SequencerBase

protected:
/** Construction */
Sequencer ();
SequencerBar();
/** Destruction */
~Sequencer ();
~SequencerBar();

/** Puts text to the status bar */
void setText (const char* pszTxt) override;
Expand All @@ -134,8 +134,8 @@ class GuiExport Sequencer : public Base::SequencerBase
/** Throws an exception to stop the pending operation. */
void abort();
//@}
SequencerPrivate* d;
static Sequencer* _pclSingleton;
SequencerBarPrivate* d;
static SequencerBar* _pclSingleton;

friend class ProgressBar;
};
Expand All @@ -146,7 +146,7 @@ class ProgressBar : public QProgressBar

public:
/** Construction */
ProgressBar (Sequencer* s, QWidget * parent=0);
ProgressBar (SequencerBar* s, QWidget * parent=0);
/** Destruction */
~ProgressBar ();

Expand Down Expand Up @@ -196,15 +196,15 @@ protected Q_SLOTS:

//@}
ProgressBarPrivate* d;
Sequencer* sequencer;
SequencerBar* sequencer;

#ifdef QT_WINEXTRAS_LIB
/* Set up the taskbar progress in windows */
void setupTaskBarProgress(void);
QWinTaskbarProgress* m_taskbarProgress;
QWinTaskbarButton* m_taskbarButton;
#endif
friend class Sequencer;
friend class SequencerBar;
};

} // namespace Gui
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Web/Gui/BrowserView.cpp
Expand Up @@ -683,7 +683,7 @@ QUrl BrowserView::url() const

void BrowserView::onLoadStarted()
{
QProgressBar* bar = Gui::Sequencer::instance()->getProgressBar();
QProgressBar* bar = Gui::SequencerBar::instance()->getProgressBar();
bar->setRange(0, 100);
bar->show();
Gui::getMainWindow()->showMessage(tr("Loading %1...").arg(view->url().toString()));
Expand All @@ -692,14 +692,14 @@ void BrowserView::onLoadStarted()

void BrowserView::onLoadProgress(int step)
{
QProgressBar* bar = Gui::Sequencer::instance()->getProgressBar();
QProgressBar* bar = Gui::SequencerBar::instance()->getProgressBar();
bar->setValue(step);
}

void BrowserView::onLoadFinished(bool ok)
{
if (ok) {
QProgressBar* bar = Sequencer::instance()->getProgressBar();
QProgressBar* bar = SequencerBar::instance()->getProgressBar();
bar->setValue(100);
bar->hide();
getMainWindow()->showMessage(QString());
Expand Down

0 comments on commit 5c17f71

Please sign in to comment.