diff options
| author | Mike Skec <skec@protonmail.ch> | 2021-01-09 14:27:44 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-01-10 13:40:46 +0100 |
| commit | dd3e8716b276f9f1646338f8801ca9a2f688fc46 (patch) | |
| tree | c2f4651e5aa539e72e3ecf9ae1a005c2b8e9e106 /src | |
| parent | 601887655e7f128c1c938a24fc38d002a8aecb64 (diff) | |
| download | kristall-dd3e8716b276f9f1646338f8801ca9a2f688fc46.tar.gz | |
status bar: New file cache indicator
Mime label was also simplified so that only type/subtype are shown.
Diffstat (limited to 'src')
| -rw-r--r-- | src/browsertab.cpp | 2 | ||||
| -rw-r--r-- | src/browsertab.hpp | 1 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 6 | ||||
| -rw-r--r-- | src/mainwindow.hpp | 1 | ||||
| -rw-r--r-- | src/mimeparser.cpp | 17 | ||||
| -rw-r--r-- | src/mimeparser.hpp | 2 |
6 files changed, 21 insertions, 8 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index c330eb0..0bb1133 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -516,6 +516,7 @@ void BrowserTab::on_requestComplete(const QByteArray &ref_data, const MimeType & this->current_stats.file_size = ref_data.size(); this->current_stats.mime_type = mime; this->current_stats.loading_time = this->timer.elapsed(); + this->current_stats.loaded_from_cache = was_read_from_cache; emit this->fileLoaded(this->current_stats); this->updateMouseCursor(false); @@ -1171,6 +1172,7 @@ void BrowserTab::on_requestProgress(qint64 transferred) this->current_stats.file_size = transferred; this->current_stats.mime_type = MimeType { }; this->current_stats.loading_time = this->timer.elapsed(); + this->current_stats.loaded_from_cache = false; emit this->fileLoaded(this->current_stats); this->network_timeout_timer.stop(); diff --git a/src/browsertab.hpp b/src/browsertab.hpp index d706f72..9b0d662 100644 --- a/src/browsertab.hpp +++ b/src/browsertab.hpp @@ -34,6 +34,7 @@ struct DocumentStats int loading_time = 0; // in ms MimeType mime_type; qint64 file_size = 0; + bool loaded_from_cache = false; bool isValid() const { return mime_type.isValid(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4a09811..26f49ec 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -24,6 +24,7 @@ MainWindow::MainWindow(QApplication * app, QWidget *parent) : ui(new Ui::MainWindow), url_status(new ElideLabel(this)), file_size(new QLabel(this)), + file_cached(new QLabel(this)), file_mime(new QLabel(this)), load_time(new QLabel(this)) { @@ -32,6 +33,7 @@ MainWindow::MainWindow(QApplication * app, QWidget *parent) : this->url_status->setElideMode(Qt::ElideMiddle); this->statusBar()->addWidget(this->url_status); + this->statusBar()->addPermanentWidget(this->file_cached); this->statusBar()->addPermanentWidget(this->file_mime); this->statusBar()->addPermanentWidget(this->file_size); this->statusBar()->addPermanentWidget(this->load_time); @@ -419,10 +421,12 @@ void MainWindow::setFileStatus(const DocumentStats &stats) { if(stats.isValid()) { this->file_size->setText(IoUtil::size_human(stats.file_size)); - this->file_mime->setText(stats.mime_type.toString()); + this->file_cached->setText(stats.loaded_from_cache ? "(cached)" : ""); + this->file_mime->setText(stats.mime_type.toString(false)); this->load_time->setText(QString("%1 ms").arg(stats.loading_time)); } else { this->file_size->setText(""); + this->file_cached->setText(""); this->file_mime->setText(""); this->load_time->setText(""); } diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp index 6a7164e..8b092f3 100644 --- a/src/mainwindow.hpp +++ b/src/mainwindow.hpp @@ -114,6 +114,7 @@ private: ElideLabel * url_status; QLabel * file_size; + QLabel * file_cached; QLabel * file_mime; QLabel * load_time; }; diff --git a/src/mimeparser.cpp b/src/mimeparser.cpp index e76f372..3a43acf 100644 --- a/src/mimeparser.cpp +++ b/src/mimeparser.cpp @@ -20,18 +20,23 @@ QString MimeType::parameter(const QString ¶m_name, QString const & default_v return val; } -QString MimeType::toString() const +QString MimeType::toString(bool full) const { if(isValid()) { QString result = type; if(not subtype.isEmpty()) result += "/" + subtype; - for(auto const & key : parameters.keys()) { - result += "; "; - result += key; - result += "="; - result += parameters[key]; + + if (full) + { + for(auto const & key : parameters.keys()) { + result += "; "; + result += key; + result += "="; + result += parameters[key]; + } } + return result; } else { return QString { }; diff --git a/src/mimeparser.hpp b/src/mimeparser.hpp index 099529d..c39299f 100644 --- a/src/mimeparser.hpp +++ b/src/mimeparser.hpp @@ -19,7 +19,7 @@ struct MimeType return not type.isEmpty(); } - QString toString() const; + QString toString(bool full = true) const; }; struct MimeParser |
