2013-05-08 01:36:34 +00:00
|
|
|
#include "editorpage.hpp"
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QListView>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QStyle>
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
#include <QPlastiqueStyle>
|
|
|
|
#endif
|
|
|
|
|
2013-05-10 15:00:58 +00:00
|
|
|
#include "../../model/settings/usersettings.hpp"
|
2013-05-08 01:36:34 +00:00
|
|
|
#include "groupblock.hpp"
|
|
|
|
#include "toggleblock.hpp"
|
|
|
|
|
2013-05-11 10:55:46 +00:00
|
|
|
CSVSettings::EditorPage::EditorPage(QWidget *parent):
|
2013-05-08 01:36:34 +00:00
|
|
|
AbstractPage("Editor", parent)
|
|
|
|
{
|
|
|
|
// Hacks to get the stylesheet look properly
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
QPlastiqueStyle *style = new QPlastiqueStyle;
|
|
|
|
//profilesComboBox->setStyle(style);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
setupUi();
|
|
|
|
}
|
|
|
|
|
2013-05-11 10:55:46 +00:00
|
|
|
void CSVSettings::EditorPage::setupUi()
|
2013-05-08 01:36:34 +00:00
|
|
|
{
|
|
|
|
GroupBlockDef undoStack (QString("Undo Stack Size"));
|
|
|
|
GroupBlockDef topLevelWindowCount (QString("Maximum Top-Level Window Count"));
|
|
|
|
GroupBlockDef reuseSubwindow (QString("Reuse Subwindows"));
|
|
|
|
GroupBlockDef customWindowSize (QString ("Custom Window Size"));
|
|
|
|
GroupBlockDef definedWindowSize (QString ("Pre-Defined Window Size"));
|
|
|
|
GroupBlockDef windowSizeToggle (QString ("Window Size"));
|
|
|
|
CustomBlockDef windowSize (QString ("Window Size"));
|
|
|
|
|
|
|
|
////////////////////////////
|
|
|
|
//undo stack size property
|
|
|
|
///////////////////////////
|
|
|
|
|
|
|
|
SettingsItemDef *undoStackItem = new SettingsItemDef (undoStack.title, "32");
|
|
|
|
undoStack.properties << undoStackItem;
|
|
|
|
undoStackItem->minMax.left = "0";
|
|
|
|
undoStackItem->minMax.right = "64";
|
|
|
|
|
2013-05-12 19:28:36 +00:00
|
|
|
WidgetDef stackWidget (Widget_SpinBox);
|
2013-05-08 01:36:34 +00:00
|
|
|
stackWidget.minMax = &(undoStackItem->minMax);
|
|
|
|
stackWidget.widgetWidth = 50;
|
|
|
|
|
|
|
|
undoStackItem->widget = stackWidget;
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
//number of top level windows property
|
|
|
|
/////////////////////////////////////
|
|
|
|
|
|
|
|
SettingsItemDef *topLevelItem = new SettingsItemDef (topLevelWindowCount.title, "100");
|
|
|
|
topLevelWindowCount.properties << topLevelItem;
|
|
|
|
topLevelItem->minMax.left = "1";
|
|
|
|
topLevelItem->minMax.right = "256";
|
|
|
|
|
2013-05-12 19:28:36 +00:00
|
|
|
WidgetDef topLvlWinWidget (Widget_SpinBox);
|
2013-05-08 01:36:34 +00:00
|
|
|
topLvlWinWidget.minMax = &(topLevelItem->minMax);
|
|
|
|
topLvlWinWidget.widgetWidth = 50;
|
|
|
|
|
|
|
|
topLevelItem->widget = topLvlWinWidget;
|
|
|
|
|
|
|
|
///////////////////////////
|
|
|
|
//reuse subwindows property
|
|
|
|
////////////////////////////
|
|
|
|
|
|
|
|
SettingsItemDef *reuseSubItem = new SettingsItemDef (reuseSubwindow.title, "Reuse Subwindows");
|
|
|
|
*(reuseSubItem->valueList) << "None" << "Top-Level" << "Document-Level";
|
|
|
|
|
2013-05-12 19:28:36 +00:00
|
|
|
WidgetDef reuseSubWidget (Widget_RadioButton);
|
2013-05-08 01:36:34 +00:00
|
|
|
reuseSubWidget.valueList = (reuseSubItem->valueList);
|
2013-05-12 19:28:36 +00:00
|
|
|
reuseSubWidget.widgetAlignment = Align_Left;
|
2013-05-08 01:36:34 +00:00
|
|
|
|
|
|
|
reuseSubwindow.properties << reuseSubItem;
|
|
|
|
reuseSubItem->widget = reuseSubWidget;
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
//custom window size properties
|
|
|
|
///////////////////////////////
|
|
|
|
|
|
|
|
//custom width
|
|
|
|
SettingsItemDef *widthItem = new SettingsItemDef ("Window Width", "640");
|
2013-05-12 19:28:36 +00:00
|
|
|
widthItem->widget = WidgetDef (Widget_LineEdit);
|
2013-05-08 01:36:34 +00:00
|
|
|
widthItem->widget.widgetWidth = 45;
|
|
|
|
|
|
|
|
//custom height
|
|
|
|
SettingsItemDef *heightItem = new SettingsItemDef ("Window Height", "480");
|
2013-05-12 19:28:36 +00:00
|
|
|
heightItem->widget = WidgetDef (Widget_LineEdit);
|
2013-05-08 01:36:34 +00:00
|
|
|
heightItem->widget.widgetWidth = 45;
|
|
|
|
heightItem->widget.caption = "x";
|
|
|
|
|
|
|
|
customWindowSize.properties << widthItem << heightItem;
|
2013-05-12 19:28:36 +00:00
|
|
|
customWindowSize.widgetOrientation = Orient_Horizontal;
|
2013-05-08 01:36:34 +00:00
|
|
|
customWindowSize.isVisible = false;
|
|
|
|
|
|
|
|
|
|
|
|
//pre-defined
|
|
|
|
SettingsItemDef *widthByHeightItem = new SettingsItemDef ("Window Size", "640x480");
|
2013-05-12 19:28:36 +00:00
|
|
|
WidgetDef widthByHeightWidget = WidgetDef (Widget_ComboBox);
|
2013-05-08 01:36:34 +00:00
|
|
|
widthByHeightWidget.widgetWidth = 90;
|
|
|
|
*(widthByHeightItem->valueList) << "640x480" << "800x600" << "1024x768";
|
|
|
|
|
|
|
|
QStringList *widthProxy = new QStringList;
|
|
|
|
QStringList *heightProxy = new QStringList;
|
|
|
|
|
|
|
|
(*widthProxy) << "Window Width" << "640" << "800" << "1024";
|
|
|
|
(*heightProxy) << "Window Height" << "480" << "600" << "768";
|
|
|
|
|
|
|
|
*(widthByHeightItem->proxyList) << widthProxy << heightProxy;
|
|
|
|
|
|
|
|
widthByHeightItem->widget = widthByHeightWidget;
|
|
|
|
|
|
|
|
definedWindowSize.properties << widthByHeightItem;
|
|
|
|
definedWindowSize.isProxy = true;
|
|
|
|
definedWindowSize.isVisible = false;
|
|
|
|
|
|
|
|
// window size toggle
|
|
|
|
windowSizeToggle.captions << "Pre-Defined" << "Custom";
|
2013-05-12 19:28:36 +00:00
|
|
|
windowSizeToggle.widgetOrientation = Orient_Vertical;
|
2013-05-08 01:36:34 +00:00
|
|
|
windowSizeToggle.isVisible = false;
|
|
|
|
|
|
|
|
//define a widget for each group in the toggle
|
|
|
|
for (int i = 0; i < 2; i++)
|
2013-05-12 19:28:36 +00:00
|
|
|
windowSizeToggle.widgets << new WidgetDef (Widget_RadioButton);
|
2013-05-08 01:36:34 +00:00
|
|
|
|
|
|
|
windowSizeToggle.widgets.at(0)->isDefault = false;
|
|
|
|
|
|
|
|
windowSize.blockDefList << &windowSizeToggle << &definedWindowSize << &customWindowSize;
|
|
|
|
windowSize.defaultValue = "Custom";
|
|
|
|
|
|
|
|
QGridLayout *pageLayout = new QGridLayout(this);
|
|
|
|
|
|
|
|
setLayout (pageLayout);
|
|
|
|
|
|
|
|
mAbstractBlocks << buildBlock<GroupBlock> (topLevelWindowCount)
|
|
|
|
<< buildBlock<GroupBlock> (reuseSubwindow)
|
|
|
|
<< buildBlock<ToggleBlock> (windowSize)
|
|
|
|
<< buildBlock<GroupBlock> (undoStack);
|
|
|
|
|
|
|
|
foreach (AbstractBlock *block, mAbstractBlocks)
|
|
|
|
{
|
|
|
|
connect (block, SIGNAL (signalUpdateSetting (const QString &, const QString &)),
|
|
|
|
this, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-11 10:55:46 +00:00
|
|
|
void CSVSettings::EditorPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
2013-05-08 01:36:34 +00:00
|
|
|
{
|
|
|
|
//iterate each item in each blocks in this section
|
|
|
|
//validate the corresponding setting against the defined valuelist if any.
|
|
|
|
for (AbstractBlockList::Iterator it_block = mAbstractBlocks.begin();
|
|
|
|
it_block != mAbstractBlocks.end(); ++it_block)
|
|
|
|
(*it_block)->updateSettings (settings);
|
|
|
|
}
|