From 6e3f512c611d586ab4922adb585286bd203f53ad Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 27 Mar 2011 19:16:54 +0900 Subject: [PATCH] Added --show-console-readout option. This option toggles appearance of console readout. --- src/ConsoleStatCalc.cc | 9 +++++++-- src/ConsoleStatCalc.h | 6 ++++++ src/OptionHandlerFactory.cc | 8 ++++++++ src/main.cc | 7 +++++-- src/prefs.cc | 2 ++ src/prefs.h | 2 ++ src/usage_text.h | 2 ++ 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc index d1093148..df5fe404 100644 --- a/src/ConsoleStatCalc.cc +++ b/src/ConsoleStatCalc.cc @@ -229,7 +229,8 @@ void printProgressSummary } // namespace ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval, bool humanReadable): - summaryInterval_(summaryInterval) + summaryInterval_(summaryInterval), + readoutVisibility_(true) { if(humanReadable) { sizeFormatter_.reset(new AbbrevSizeFormatter()); @@ -276,7 +277,11 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) sizeFormatter); std::cout << "\n"; } - + } + if(!readoutVisibility_) { + return; + } + if(e->getRequestGroupMan()->countRequestGroup() > 0) { SharedHandle firstRequestGroup = e->getRequestGroupMan()->getRequestGroup(0); diff --git a/src/ConsoleStatCalc.h b/src/ConsoleStatCalc.h index d13f34fe..dd134e43 100644 --- a/src/ConsoleStatCalc.h +++ b/src/ConsoleStatCalc.h @@ -62,12 +62,18 @@ private: time_t summaryInterval_; SharedHandle sizeFormatter_; + bool readoutVisibility_; public: ConsoleStatCalc(time_t summaryInterval, bool humanReadable = true); virtual ~ConsoleStatCalc() {} virtual void calculateStat(const DownloadEngine* e); + + void setReadoutVisibility(bool visibility) + { + readoutVisibility_ = visibility; + } }; typedef SharedHandle ConsoleStatCalcHandle; diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 59555e6e..b3030154 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -561,6 +561,14 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() op->hide(); handlers.push_back(op); } + { + SharedHandle op(new BooleanOptionHandler + (PREF_SHOW_CONSOLE_READOUT, + TEXT_SHOW_CONSOLE_READOUT, + A2_V_TRUE)); + op->addTag(TAG_ADVANCED); + handlers.push_back(op); + } { SharedHandle op(new NumberOptionHandler (PREF_STOP, diff --git a/src/main.cc b/src/main.cc index 6b9fefbc..81e5391a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -94,8 +94,11 @@ SharedHandle getStatCalc(const SharedHandle