2013-05-08 01:33:42 +00:00
|
|
|
#ifndef USERSETTINGSDIALOG_H
|
|
|
|
#define USERSETTINGSDIALOG_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QStackedWidget>
|
2013-05-22 08:14:12 +00:00
|
|
|
#include <QListWidgetItem>
|
2013-06-15 11:40:18 +00:00
|
|
|
#include <QApplication>
|
2013-05-16 17:46:04 +00:00
|
|
|
|
2013-05-10 15:00:58 +00:00
|
|
|
#include "../../model/settings/usersettings.hpp"
|
|
|
|
#include "../../model/settings/support.hpp"
|
2013-05-08 01:33:42 +00:00
|
|
|
|
2013-06-15 11:40:18 +00:00
|
|
|
#include "editorpage.hpp"
|
|
|
|
|
2013-05-08 01:33:42 +00:00
|
|
|
class QHBoxLayout;
|
|
|
|
class AbstractWidget;
|
|
|
|
class QStackedWidget;
|
|
|
|
class QListWidget;
|
|
|
|
|
2013-05-11 10:55:46 +00:00
|
|
|
namespace CSVSettings {
|
2013-05-08 01:33:42 +00:00
|
|
|
|
|
|
|
class AbstractPage;
|
2013-05-12 20:15:57 +00:00
|
|
|
|
2013-05-08 01:33:42 +00:00
|
|
|
class UserSettingsDialog : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QListWidget *mListWidget;
|
|
|
|
QStackedWidget *mStackedWidget;
|
|
|
|
|
|
|
|
public:
|
|
|
|
UserSettingsDialog(QMainWindow *parent = 0);
|
|
|
|
~UserSettingsDialog();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// Settings are written on close
|
2013-05-08 01:33:42 +00:00
|
|
|
void closeEvent (QCloseEvent *event);
|
2013-06-20 23:06:25 +00:00
|
|
|
|
|
|
|
/// return the setting page by name
|
|
|
|
/// performs dynamic cast to AbstractPage *
|
2013-05-08 01:33:42 +00:00
|
|
|
AbstractPage *getAbstractPage (int index);
|
2013-06-15 11:40:18 +00:00
|
|
|
void setWidgetStates ();
|
2013-05-08 01:33:42 +00:00
|
|
|
void buildPages();
|
|
|
|
void writeSettings();
|
2013-06-08 22:34:27 +00:00
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// Templated function to create a custom user preference page
|
2013-05-08 01:33:42 +00:00
|
|
|
template <typename T>
|
2013-06-20 23:06:25 +00:00
|
|
|
void createPage ()
|
2013-05-08 01:33:42 +00:00
|
|
|
{
|
2013-06-20 23:06:25 +00:00
|
|
|
T *page = new T(mStackedWidget);
|
2013-05-08 01:33:42 +00:00
|
|
|
|
|
|
|
mStackedWidget->addWidget (dynamic_cast<QWidget *>(page));
|
|
|
|
|
|
|
|
new QListWidgetItem (page->objectName(), mListWidget);
|
|
|
|
|
|
|
|
//finishing touches
|
2013-06-15 11:40:18 +00:00
|
|
|
QFontMetrics fm (QApplication::font());
|
|
|
|
int textWidth = fm.width(page->objectName());
|
|
|
|
|
|
|
|
if ((textWidth + 50) > mListWidget->minimumWidth())
|
|
|
|
mListWidget->setMinimumWidth(textWidth + 50);
|
|
|
|
|
2013-05-08 01:33:42 +00:00
|
|
|
resize (mStackedWidget->sizeHint());
|
|
|
|
}
|
|
|
|
|
|
|
|
public slots:
|
2013-06-20 23:06:25 +00:00
|
|
|
|
|
|
|
/// Called when a different page is selected in the left-hand list widget
|
2013-05-08 01:33:42 +00:00
|
|
|
void slotChangePage (QListWidgetItem*, QListWidgetItem*);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // USERSETTINGSDIALOG_H
|