diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-06-10 16:43:39 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-06-12 15:47:36 -0400 |
| commit | 853c95b921f4fc3beb8daf71d79b44aa1ab06c92 (patch) | |
| tree | a15273573d026744cf68dfe2ed4260ad08f81e87 /src | |
| parent | 54f3188a06c7dbc4ac844aba9b50dc4684d6b9c3 (diff) | |
added new statusbar class, moved refresh progress bar to it
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 20 | ||||
| -rw-r--r-- | src/mainwindow.h | 5 | ||||
| -rw-r--r-- | src/statusbar.cpp | 27 | ||||
| -rw-r--r-- | src/statusbar.h | 20 |
5 files changed, 57 insertions, 18 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93597d62..71f87a8a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -116,6 +116,7 @@ SET(organizer_SRCS forcedloaddialog.cpp forcedloaddialogwidget.cpp filterwidget.cpp + statusbar.cpp shared/windows_error.cpp shared/error_report.cpp @@ -213,6 +214,7 @@ SET(organizer_HDRS forcedloaddialog.h forcedloaddialogwidget.h filterwidget.h + statusbar.h shared/windows_error.h shared/error_report.h @@ -277,6 +279,7 @@ set(application moshortcut selfupdater singleinstance + statusbar ) set(browser diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 911d0ff1..67d0f2ff 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -77,6 +77,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "nxmaccessmanager.h" #include "appconfig.h" #include "eventfilter.h" +#include "statusbar.h" #include <utility.h> #include <dataarchives.h> #include <bsainvalidation.h> @@ -242,13 +243,7 @@ MainWindow::MainWindow(QSettings &initSettings connect(ui->logList->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->logList, SLOT(scrollToBottom())); - m_RefreshProgress = new QProgressBar(statusBar()); - m_RefreshProgress->setTextVisible(true); - m_RefreshProgress->setRange(0, 100); - m_RefreshProgress->setValue(0); - m_RefreshProgress->setVisible(false); - statusBar()->addWidget(m_RefreshProgress, 1000); - statusBar()->clearMessage(); + m_statusBar.reset(new StatusBar(statusBar())); updateProblemsButton(); @@ -2534,15 +2529,8 @@ void MainWindow::setESPListSorting(int index) void MainWindow::refresher_progress(int percent) { - if (percent == 100) { - m_RefreshProgress->setVisible(false); - this->setEnabled(true); - } else if (!m_RefreshProgress->isVisible()) { - this->setEnabled(false); - m_RefreshProgress->setVisible(true); - m_RefreshProgress->setRange(0, 100); - m_RefreshProgress->setValue(percent); - } + setEnabled(percent == 100); + m_statusBar->setProgress(percent); } void MainWindow::directory_refreshed() diff --git a/src/mainwindow.h b/src/mainwindow.h index b8d9f49f..734ece88 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -37,6 +37,7 @@ struct Executable; class CategoryFactory; class LockedDialogBase; class OrganizerCore; +class StatusBar; #include "plugincontainer.h" //class PluginContainer; class PluginListSortProxy; namespace BSA { class Archive; } @@ -75,7 +76,6 @@ class QListWidgetItem; class QMenu; class QModelIndex; class QPoint; -class QProgressBar; class QProgressDialog; class QTranslator; class QTreeWidgetItem; @@ -329,6 +329,8 @@ private: // the window is closed and the menubar is hidden bool m_menuBarVisible; + std::unique_ptr<StatusBar> m_statusBar; + // last separator on the toolbar, used to add spacer for right-alignment and // as an insert point for executables QAction* m_linksSeparator; @@ -338,7 +340,6 @@ private: int m_OldProfileIndex; std::vector<QString> m_ModNameList; // the mod-list to go with the directory structure - QProgressBar *m_RefreshProgress; bool m_Refreshing; QStringList m_DefaultArchives; diff --git a/src/statusbar.cpp b/src/statusbar.cpp new file mode 100644 index 00000000..7370662a --- /dev/null +++ b/src/statusbar.cpp @@ -0,0 +1,27 @@ +#include "statusbar.h" + +StatusBar::StatusBar(QStatusBar* bar) + : m_bar(bar), m_nexusAPI(new QLabel), m_progress(new QProgressBar) +{ + m_progress->setTextVisible(true); + m_progress->setRange(0, 100); + m_progress->setValue(0); + m_progress->setVisible(false); + + m_bar->addPermanentWidget(m_nexusAPI); + m_bar->addPermanentWidget(m_progress); + + m_bar->clearMessage(); +} + +void StatusBar::setProgress(int percent) +{ + qDebug().nospace() << "progress: " << percent; + + if (percent < 0 || percent >= 100) { + m_progress->setVisible(false); + } else if (!m_progress->isVisible()) { + m_progress->setVisible(true); + m_progress->setValue(percent); + } +} diff --git a/src/statusbar.h b/src/statusbar.h new file mode 100644 index 00000000..f3ad3081 --- /dev/null +++ b/src/statusbar.h @@ -0,0 +1,20 @@ +#ifndef MO_STATUSBAR_H +#define MO_STATUSBAR_H + +#include <QStatusBar> +#include <QProgressBar> + +class StatusBar +{ +public: + StatusBar(QStatusBar* bar); + + void setProgress(int percent); + +private: + QStatusBar* m_bar; + QLabel* m_api; + QProgressBar* m_progress; +}; + +#endif // MO_STATUSBAR_H |
