Rewrite feature to reset options to default
parent
f30d1a3075
commit
3545cfa00a
@ -0,0 +1,32 @@
|
||||
#include "contextmenulist.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
#include "../../model/prefs/state.hpp"
|
||||
|
||||
CSVPrefs::ContextMenuList::ContextMenuList(QWidget* parent)
|
||||
:QListWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CSVPrefs::ContextMenuList::contextMenuEvent(QContextMenuEvent* e)
|
||||
{
|
||||
QMenu* menu = new QMenu();
|
||||
|
||||
menu->addAction("Reset category to default", this, SLOT(resetCategory()));
|
||||
menu->addAction("Reset all to default", this, SLOT(resetAll()));
|
||||
|
||||
menu->exec(e->globalPos());
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void CSVPrefs::ContextMenuList::resetCategory()
|
||||
{
|
||||
CSMPrefs::State::get().resetCategory(currentItem()->text().toStdString());
|
||||
}
|
||||
|
||||
void CSVPrefs::ContextMenuList::resetAll()
|
||||
{
|
||||
CSMPrefs::State::get().resetAll();
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#ifndef CSV_PREFS_CONTEXTMENULIST_H
|
||||
#define CSV_PREFS_CONTEXTMENULIST_H
|
||||
|
||||
#include <QListWidget>
|
||||
|
||||
class QContextMenuEvent;
|
||||
|
||||
namespace CSVPrefs
|
||||
{
|
||||
class ContextMenuList : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
ContextMenuList(QWidget* parent = 0);
|
||||
|
||||
protected:
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent* e);
|
||||
|
||||
private slots:
|
||||
|
||||
void resetCategory();
|
||||
|
||||
void resetAll();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,33 @@
|
||||
#include "contextmenuwidget.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
#include "../../model/prefs/state.hpp"
|
||||
|
||||
CSVPrefs::ContextMenuWidget::ContextMenuWidget(QWidget* parent, const std::string& category)
|
||||
:QWidget(parent)
|
||||
,mCategory(category)
|
||||
{
|
||||
}
|
||||
|
||||
void CSVPrefs::ContextMenuWidget::contextMenuEvent(QContextMenuEvent* e)
|
||||
{
|
||||
QMenu* menu = new QMenu();
|
||||
|
||||
menu->addAction("Reset category to default", this, SLOT(resetCategory()));
|
||||
menu->addAction("Reset all to default", this, SLOT(resetAll()));
|
||||
|
||||
menu->exec(e->globalPos());
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void CSVPrefs::ContextMenuWidget::resetCategory()
|
||||
{
|
||||
CSMPrefs::State::get().resetCategory(mCategory);
|
||||
}
|
||||
|
||||
void CSVPrefs::ContextMenuWidget::resetAll()
|
||||
{
|
||||
CSMPrefs::State::get().resetAll();
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef CSV_PREFS_CONTEXTMENUWIDGET_H
|
||||
#define CSV_PREFS_CONTEXTMENUWIDGET_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QContextMenuEvent;
|
||||
|
||||
namespace CSVPrefs
|
||||
{
|
||||
class ContextMenuWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
ContextMenuWidget(QWidget* parent, const std::string& category);
|
||||
|
||||
protected:
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent* e);
|
||||
|
||||
private slots:
|
||||
|
||||
void resetCategory();
|
||||
|
||||
void resetAll();
|
||||
|
||||
private:
|
||||
|
||||
std::string mCategory;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue