Skip to content

Commit

Permalink
Only enable non-default presets in presets model and some style impro…
Browse files Browse the repository at this point in the history
…vements (#755)
  • Loading branch information
ThomasKroes authored Dec 18, 2024
1 parent 4c22067 commit b4d6a97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
29 changes: 13 additions & 16 deletions ManiVault/src/actions/PresetsAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <QHBoxLayout>
#include <QHeaderView>
#include <QMenu>
#include <QLocale>
#include <QFileDialog>
#include <QStringListModel>

Expand All @@ -18,9 +17,9 @@

namespace mv::gui {

QMap<PresetsAction::Column, QPair<QString, QString>> PresetsAction::columnInfo = QMap<PresetsAction::Column, QPair<QString, QString>>({
{ PresetsAction::Column::Name, { "Name", "Preset name" }},
{ PresetsAction::Column::DateTime, { "Date and time", "Date and time when the preset was changed" }}
QMap<PresetsAction::Column, QPair<QString, QString>> PresetsAction::columnInfo = QMap<Column, QPair<QString, QString>>({
{ Column::Name, { "Name", "Preset name" }},
{ Column::DateTime, { "Date and time", "Date and time when the preset was changed" }}
});

PresetsAction::PresetsAction(QObject* parent, WidgetAction* sourceAction, const QString& settingsKey /*= ""*/, const QString& presetType /*= ""*/, const QIcon& icon /*= QIcon()*/) :
Expand All @@ -31,8 +30,7 @@ PresetsAction::PresetsAction(QObject* parent, WidgetAction* sourceAction, const
_icon(icon),
_model(this),
_filterModel(this),
_editAction(this, "Edit..."),
_presets()
_editAction(this, "Edit...")
{
Q_ASSERT(_sourceAction != nullptr);

Expand Down Expand Up @@ -92,7 +90,7 @@ void PresetsAction::loadPresetsFromApplicationSettings()
updateModel();
}

void PresetsAction::savePresetsToApplicationSettings()
void PresetsAction::savePresetsToApplicationSettings() const
{
#ifdef PRESETS_ACTION_VERBOSE
qDebug() << __FUNCTION__;
Expand Down Expand Up @@ -351,7 +349,7 @@ void PresetsAction::updateModel()

dateTimeItem->setData(dateTime, Qt::EditRole);

const auto itemEnabled = true;// presetName != "Default";
const auto itemEnabled = presetName != "Default";

nameItem->setEnabled(itemEnabled);
dateTimeItem->setEnabled(itemEnabled);
Expand Down Expand Up @@ -464,11 +462,10 @@ PresetsAction::ChoosePresetNameDialog::ChoosePresetNameDialog(PresetsAction* pre

QSize PresetsAction::ChoosePresetNameDialog::sizeHint() const
{
return QSize(300, 0);
return { 300, 0 };
}

PresetsAction::ManagePresetsDialog::ManagePresetsDialog(PresetsAction* presetsAction) :
QDialog(),
_hierarchyWidget(this, QString("%1 Preset").arg(presetsAction->getPresetType()), presetsAction->getModel(), const_cast<PresetsAction::FilterModel*>(&presetsAction->getFilterModel())),
_removeAction(this, "Remove"),
_okAction(this, "Ok")
Expand Down Expand Up @@ -507,12 +504,12 @@ PresetsAction::ManagePresetsDialog::ManagePresetsDialog(PresetsAction* presetsAc

treeViewHeader->setStretchLastSection(false);

treeViewHeader->setSortIndicator(static_cast<int>(PresetsAction::Column::Name), Qt::DescendingOrder);
treeViewHeader->setSortIndicator(static_cast<int>(Column::Name), Qt::DescendingOrder);

treeViewHeader->resizeSection(static_cast<int>(PresetsAction::Column::DateTime), 100);
treeViewHeader->resizeSection(static_cast<int>(Column::DateTime), 100);

treeViewHeader->setSectionResizeMode(static_cast<int>(PresetsAction::Column::Name), QHeaderView::Stretch);
treeViewHeader->setSectionResizeMode(static_cast<int>(PresetsAction::Column::DateTime), QHeaderView::Fixed);
treeViewHeader->setSectionResizeMode(static_cast<int>(Column::Name), QHeaderView::Stretch);
treeViewHeader->setSectionResizeMode(static_cast<int>(Column::DateTime), QHeaderView::Fixed);

_removeAction.setEnabled(false);

Expand All @@ -537,7 +534,7 @@ PresetsAction::ManagePresetsDialog::ManagePresetsDialog(PresetsAction* presetsAc
QStringList presetsToRemove;

for (const auto& selectedRow : selectedRows)
presetsToRemove << selectedRow.siblingAtColumn(static_cast<int>(PresetsAction::Column::Name)).data().toString();
presetsToRemove << selectedRow.siblingAtColumn(static_cast<int>(Column::Name)).data().toString();

presetsAction->removePresets(presetsToRemove);
});
Expand All @@ -547,7 +544,7 @@ PresetsAction::ManagePresetsDialog::ManagePresetsDialog(PresetsAction* presetsAc

QSize PresetsAction::ManagePresetsDialog::sizeHint() const
{
return QSize(480, 480);
return { 480, 480 };
}

}
2 changes: 1 addition & 1 deletion ManiVault/src/actions/PresetsAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class CORE_EXPORT PresetsAction final : public WidgetAction
void loadPresetsFromApplicationSettings();

/** Save presets variant map to application settings */
void savePresetsToApplicationSettings();
void savePresetsToApplicationSettings() const;

/**
* Get recent file paths menu
Expand Down
1 change: 1 addition & 0 deletions resharper.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />

0 comments on commit b4d6a97

Please sign in to comment.