summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorLostDragonist <lost.dragonist@gmail.com>2019-01-01 17:07:52 -0600
committerLostDragonist <lost.dragonist@gmail.com>2019-01-01 17:07:52 -0600
commit15e47114175d7dd86cd6e774aff1d7872e87a647 (patch)
tree6bb64a158b56717ba4b5aaccc64108bffce00102 /src/mainwindow.cpp
parentd8396bfa2cde422c7522b0e6a78b0d5ab2e218ac (diff)
parent5ad411cd47fc3193c6c87a745e41bd6c09b687ab (diff)
Merge remote-tracking branch 'remotes/origin/Develop' into archive_conflicts_2
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp97
1 files changed, 58 insertions, 39 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 6b07992f..a2696770 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -55,7 +55,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "activatemodsdialog.h"
#include "downloadlist.h"
#include "downloadlistwidget.h"
-#include "downloadlistwidgetcompact.h"
#include "messagedialog.h"
#include "installationmanager.h"
#include "lockeddialog.h"
@@ -320,6 +319,7 @@ MainWindow::MainWindow(QSettings &initSettings
ui->bsaList->setLocalMoveOnly(true);
+ initDownloadView();
bool pluginListAdjusted = registerWidgetState(ui->espList->objectName(), ui->espList->header(), "plugin_list_state");
registerWidgetState(ui->dataTree->objectName(), ui->dataTree->header());
registerWidgetState(ui->downloadView->objectName(),
@@ -341,8 +341,6 @@ MainWindow::MainWindow(QSettings &initSettings
ui->openFolderMenu->setMenu(openFolderMenu());
- updateDownloadListDelegate();
-
ui->savegameList->installEventFilter(this);
ui->savegameList->setMouseTracking(true);
@@ -472,8 +470,12 @@ MainWindow::MainWindow(QSettings &initSettings
for (QAction *action : ui->toolBar->actions()) {
// set the name of the widget to the name of the action to allow styling
- ui->toolBar->widgetForAction(action)->setObjectName(action->objectName());
+ QWidget *actionWidget = ui->toolBar->widgetForAction(action);
+ actionWidget->setObjectName(action->objectName());
+ actionWidget->style()->unpolish(actionWidget);
+ actionWidget->style()->polish(actionWidget);
}
+
emit updatePluginCount();
emit updateModCount();
}
@@ -4714,7 +4716,7 @@ void MainWindow::on_actionSettings_triggered()
NexusInterface::instance(&m_PluginContainer)->setNMMVersion(settings.getNMMVersion());
- updateDownloadListDelegate();
+ updateDownloadView();
m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType(), settings.executablesBlacklist());
m_OrganizerCore.cycleDiagnostics();
@@ -4770,13 +4772,12 @@ void MainWindow::languageChange(const QString &newLanguage)
createHelpWidget();
- updateDownloadListDelegate();
+ updateDownloadView();
updateProblemsButton();
ui->listOptionsBtn->setMenu(modListContextMenu());
ui->openFolderMenu->setMenu(openFolderMenu());
-
}
void MainWindow::writeDataToFile(QFile &file, const QString &directory, const DirectoryEntry &directoryEntry)
@@ -5207,43 +5208,58 @@ void MainWindow::on_actionEndorseMO_triggered()
}
-void MainWindow::updateDownloadListDelegate()
+void MainWindow::initDownloadView()
{
- if (m_OrganizerCore.settings().compactDownloads()) {
- ui->downloadView->setItemDelegate(
- new DownloadListWidgetCompactDelegate(m_OrganizerCore.downloadManager(),
- m_OrganizerCore.settings().metaDownloads(),
- ui->downloadView,
- ui->downloadView));
- } else {
- ui->downloadView->setItemDelegate(
- new DownloadListWidgetDelegate(m_OrganizerCore.downloadManager(),
- m_OrganizerCore.settings().metaDownloads(),
- ui->downloadView,
- ui->downloadView));
- }
-
+ DownloadList *sourceModel = new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView);
DownloadListSortProxy *sortProxy = new DownloadListSortProxy(m_OrganizerCore.downloadManager(), ui->downloadView);
- sortProxy->setSourceModel(new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView));
+ sortProxy->setSourceModel(sourceModel);
connect(ui->downloadFilterEdit, SIGNAL(textChanged(QString)), sortProxy, SLOT(updateFilter(QString)));
connect(ui->downloadFilterEdit, SIGNAL(textChanged(QString)), this, SLOT(downloadFilterChanged(QString)));
+ ui->downloadView->setSourceModel(sourceModel);
ui->downloadView->setModel(sortProxy);
- //ui->downloadView->sortByColumn(1, Qt::DescendingOrder);
- ui->downloadView->header()->resizeSections(QHeaderView::Stretch);
+ ui->downloadView->setManager(m_OrganizerCore.downloadManager());
+ ui->downloadView->setItemDelegate(new DownloadProgressDelegate(m_OrganizerCore.downloadManager(), sortProxy, ui->downloadView));
+ ui->downloadView->setUniformRowHeights(false);
+ ui->downloadView->header()->setStretchLastSection(false);
+ ui->downloadView->header()->setSectionResizeMode(QHeaderView::Interactive);
+ ui->downloadView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
+ ui->downloadView->sortByColumn(1, Qt::DescendingOrder);
+ updateDownloadView();
- connect(ui->downloadView->itemDelegate(), SIGNAL(installDownload(int)), &m_OrganizerCore, SLOT(installDownload(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(queryInfo(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfo(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(visitOnNexus(int)), m_OrganizerCore.downloadManager(), SLOT(visitOnNexus(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(openFile(int)), m_OrganizerCore.downloadManager(), SLOT(openFile(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(openInDownloadsFolder(int)), m_OrganizerCore.downloadManager(), SLOT(openInDownloadsFolder(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(removeDownload(int, bool)), m_OrganizerCore.downloadManager(), SLOT(removeDownload(int, bool)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(restoreDownload(int)), m_OrganizerCore.downloadManager(), SLOT(restoreDownload(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(cancelDownload(int)), m_OrganizerCore.downloadManager(), SLOT(cancelDownload(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(pauseDownload(int)), m_OrganizerCore.downloadManager(), SLOT(pauseDownload(int)));
- connect(ui->downloadView->itemDelegate(), SIGNAL(resumeDownload(int)), this, SLOT(resumeDownload(int)));
+ connect(ui->downloadView, SIGNAL(installDownload(int)), &m_OrganizerCore, SLOT(installDownload(int)));
+ connect(ui->downloadView, SIGNAL(queryInfo(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfo(int)));
+ connect(ui->downloadView, SIGNAL(visitOnNexus(int)), m_OrganizerCore.downloadManager(), SLOT(visitOnNexus(int)));
+ connect(ui->downloadView, SIGNAL(openFile(int)), m_OrganizerCore.downloadManager(), SLOT(openFile(int)));
+ connect(ui->downloadView, SIGNAL(openInDownloadsFolder(int)), m_OrganizerCore.downloadManager(), SLOT(openInDownloadsFolder(int)));
+ connect(ui->downloadView, SIGNAL(removeDownload(int, bool)), m_OrganizerCore.downloadManager(), SLOT(removeDownload(int, bool)));
+ connect(ui->downloadView, SIGNAL(restoreDownload(int)), m_OrganizerCore.downloadManager(), SLOT(restoreDownload(int)));
+ connect(ui->downloadView, SIGNAL(cancelDownload(int)), m_OrganizerCore.downloadManager(), SLOT(cancelDownload(int)));
+ connect(ui->downloadView, SIGNAL(pauseDownload(int)), m_OrganizerCore.downloadManager(), SLOT(pauseDownload(int)));
+ connect(ui->downloadView, SIGNAL(resumeDownload(int)), this, SLOT(resumeDownload(int)));
}
+void MainWindow::updateDownloadView()
+{
+ // set the view attribute and default row sizes
+ if (m_OrganizerCore.settings().compactDownloads()) {
+ ui->downloadView->setProperty("downloadView", "compact");
+ setStyleSheet("DownloadListWidget::item { padding: 4px; }");
+ } else {
+ ui->downloadView->setProperty("downloadView", "standard");
+ setStyleSheet("DownloadListWidget::item { padding: 16px; }");
+ }
+ setStyleSheet("DownloadListWidget::item:hover { padding: 0px; }");
+ setStyleSheet("DownloadListWidget::item:selected { padding: 0px; }");
+
+ // reapply global stylesheet on the widget level (!) to override the defaults
+ ui->downloadView->setStyleSheet(styleSheet());
+
+ ui->downloadView->setMetaDisplay(m_OrganizerCore.settings().metaDownloads());
+ ui->downloadView->style()->unpolish(ui->downloadView);
+ ui->downloadView->style()->polish(ui->downloadView);
+ m_OrganizerCore.downloadManager()->refreshList();
+}
void MainWindow::modDetailsUpdated(bool)
{
@@ -6300,10 +6316,13 @@ void MainWindow::sendSelectedModsToPriority_clicked()
void MainWindow::sendSelectedModsToSeparator_clicked()
{
QStringList separators;
- for (auto mod : m_OrganizerCore.modList()->allMods()) {
- ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(mod));
- if (modInfo->hasFlag(ModInfo::FLAG_SEPARATOR)) {
- separators << mod.chopped(10);
+ auto indexesByPriority = m_OrganizerCore.currentProfile()->getAllIndexesByPriority();
+ for (auto iter = indexesByPriority.begin(); iter != indexesByPriority.end(); iter++) {
+ if ((iter->second != UINT_MAX)) {
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(iter->second);
+ if (modInfo->hasFlag(ModInfo::FLAG_SEPARATOR)) {
+ separators << modInfo->name().chopped(10);
+ }
}
}