Newer
Older
/***************************************************************************
File : ConfigDialog.cpp
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net
Description : Preferences dialog
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#include "ConfigDialog.h"
#include "ApplicationWindow.h"
#include "MultiLayer.h"
#include "Graph.h"
#include "Matrix.h"
#include "ColorButton.h"
#include "ColorBox.h"
#include "pixmaps.h"
#include "DoubleSpinBox.h"
Robert Whitley
committed
#include "SendToProgramDialog.h"
Roman Tolchenov
committed
#include "Mantid/MantidUI.h"
Anders Markvardsen
committed
#include "MantidQtMantidWidgets/FitPropertyBrowser.h"
#include <QLocale>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QGridLayout>
#include <QGroupBox>
#include <QFont>
#include <QFontDialog>
#include <QTabWidget>
#include <QStackedWidget>
#include <QWidget>
#include <QComboBox>
#include <QSpinBox>
#include <QRadioButton>
#include <QStyleFactory>
#include <QRegExp>
#include <QMessageBox>
#include <QTranslator>
#include <QApplication>
#include <QDir>
#include <QPixmap>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QListWidget>
#include <QFontMetrics>
#include <QFileDialog>
Gigg, Martyn Anthony
committed
#include <QRegExp>
#include <QMouseEvent>
Gigg, Martyn Anthony
committed
#include "MantidKernel/ConfigService.h"
Gigg, Martyn Anthony
committed
#include "MantidKernel/FacilityInfo.h"
Gigg, Martyn Anthony
committed
#include "MantidAPI/FunctionFactory.h"
#include "MantidAPI/IBackgroundFunction.h"
Roman Tolchenov
committed
#include "MantidAPI/IPeakFunction.h"
Gigg, Martyn Anthony
committed
#include "MantidQtMantidWidgets/InstrumentSelector.h"
#include "MantidQtAPI/MdConstants.h"
#include "MantidQtAPI/MdSettings.h"
#include "MantidQtAPI/MdPlottingCmapsProvider.h"
#include <limits>
using Mantid::Kernel::ConfigService;
: QDialog( parent, fl )
// get current values from app window
ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(this->parentWidget());
plot3DTitleFont = app->plot3DTitleFont;
plot3DNumbersFont = app->plot3DNumbersFont;
plot3DAxesFont = app->plot3DAxesFont;
textFont = app->tableTextFont;
headerFont = app->tableHeaderFont;
appFont = app->appFont;
axesFont = app->plotAxesFont;
numbersFont = app->plotNumbersFont;
legendFont = app->plotLegendFont;
titleFont = app->plotTitleFont;
// create the GUI
generalDialog = new QStackedWidget();
itemsList = new QListWidget();
itemsList->setSpacing(10);
itemsList->setAlternatingRowColors( true );
initAppPage();
initMantidPage();
initTablesPage();
initPlotsPage();
initPlots3DPage();
initFittingPage();
generalDialog->addWidget(appTabWidget);
generalDialog->addWidget(mtdTabWidget);
generalDialog->addWidget(tables);
generalDialog->addWidget(plotsTabWidget);
generalDialog->addWidget(plots3D);
generalDialog->addWidget(fitPage);
generalDialog->addWidget(mdPlottingTabWidget);
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
QVBoxLayout * rightLayout = new QVBoxLayout();
lblPageHeader = new QLabel();
QFont fnt = this->font();
fnt.setPointSize(fnt.pointSize() + 3);
fnt.setBold(true);
lblPageHeader->setFont(fnt);
lblPageHeader->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
QPalette pal = lblPageHeader->palette();
pal.setColor( QPalette::Window, app->panelsColor );
lblPageHeader->setPalette(pal);
lblPageHeader->setAutoFillBackground( true );
rightLayout->setSpacing(10);
rightLayout->addWidget( lblPageHeader );
rightLayout->addWidget( generalDialog );
QHBoxLayout * topLayout = new QHBoxLayout();
topLayout->setSpacing(5);
topLayout->setMargin(5);
topLayout->addWidget( itemsList );
topLayout->addLayout( rightLayout );
QHBoxLayout * bottomButtons = new QHBoxLayout();
bottomButtons->addStretch();
buttonApply = new QPushButton();
buttonApply->setAutoDefault( true );
bottomButtons->addWidget( buttonApply );
buttonOk = new QPushButton();
buttonOk->setAutoDefault( true );
buttonOk->setDefault( true );
bottomButtons->addWidget( buttonOk );
buttonCancel = new QPushButton();
buttonCancel->setAutoDefault( true );
bottomButtons->addWidget( buttonCancel );
QVBoxLayout * mainLayout = new QVBoxLayout( this );
mainLayout->addLayout(topLayout);
mainLayout->addLayout(bottomButtons);
languageChange();
// signals and slots connections
connect( itemsList, SIGNAL(currentRowChanged(int)), this, SLOT(setCurrentPage(int)));
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( buttonTextFont, SIGNAL( clicked() ), this, SLOT( pickTextFont() ) );
connect( buttonHeaderFont, SIGNAL( clicked() ), this, SLOT( pickHeaderFont() ) );
setCurrentPage(0);
generalDialog->setCurrentIndex(index);
if(itemsList->currentItem())
lblPageHeader->setText(itemsList->currentItem()->text());
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(this->parentWidget());
tables = new QWidget();
QHBoxLayout * topLayout = new QHBoxLayout();
topLayout->setSpacing(5);
lblSeparator = new QLabel();
topLayout->addWidget( lblSeparator );
boxSeparator = new QComboBox();
boxSeparator->setEditable( true );
topLayout->addWidget( boxSeparator );
QString help = tr("The column separator can be customized. \nThe following special codes can be used:\n\\t for a TAB character \n\\s for a SPACE");
help += "\n"+tr("The separator must not contain the following characters: \n0-9eE.+-");
boxSeparator->setWhatsThis(help);
boxSeparator->setToolTip(help);
lblSeparator->setWhatsThis(help);
lblSeparator->setToolTip(help);
groupBoxTableCol = new QGroupBox();
QGridLayout * colorsLayout = new QGridLayout(groupBoxTableCol);
lblTableBackground = new QLabel();
colorsLayout->addWidget( lblTableBackground, 0, 0 );
buttonBackground= new ColorButton();
buttonBackground->setColor(app->tableBkgdColor);
colorsLayout->addWidget( buttonBackground, 0, 1 );
lblTextColor = new QLabel();
colorsLayout->addWidget( lblTextColor, 1, 0 );
buttonText = new ColorButton();
buttonText->setColor(app->tableTextColor);
colorsLayout->addWidget( buttonText, 1, 1 );
lblHeaderColor = new QLabel();
colorsLayout->addWidget( lblHeaderColor, 2, 0 );
buttonHeader= new ColorButton();
buttonHeader->setColor(app->tableHeaderColor);
colorsLayout->addWidget( buttonHeader, 2, 1 );
groupBoxTableFonts = new QGroupBox();
QHBoxLayout * bottomLayout = new QHBoxLayout( groupBoxTableFonts );
buttonTextFont= new QPushButton();
bottomLayout->addWidget( buttonTextFont );
buttonHeaderFont= new QPushButton();
bottomLayout->addWidget( buttonHeaderFont );
boxTableComments = new QCheckBox();
boxTableComments->setChecked(app->d_show_table_comments);
boxUpdateTableValues = new QCheckBox();
boxUpdateTableValues->setChecked(app->autoUpdateTableValues());
QVBoxLayout * tablesPageLayout = new QVBoxLayout( tables );
tablesPageLayout->addLayout(topLayout,1);
tablesPageLayout->addWidget(groupBoxTableCol);
tablesPageLayout->addWidget(groupBoxTableFonts);
tablesPageLayout->addWidget(boxTableComments);
tablesPageLayout->addWidget(boxUpdateTableValues);
tablesPageLayout->addStretch();
ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(this->parentWidget());
if (!app) {
throw std::logic_error("Parent of ConfigDialog is not ApplicationWindow as expected.");
}
plotsTabWidget = new QTabWidget();
initOptionsPage();
initAxesPage();
plotsTabWidget->addTab( axesPage, QString() );
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
initCurvesPage();
plotsTabWidget->addTab( curves, QString() );
plotTicks = new QWidget();
QVBoxLayout * plotTicksLayout = new QVBoxLayout( plotTicks );
QGroupBox * ticksGroupBox = new QGroupBox();
QGridLayout * ticksLayout = new QGridLayout( ticksGroupBox );
plotTicksLayout->addWidget( ticksGroupBox );
lblMajTicks = new QLabel();
ticksLayout->addWidget( lblMajTicks, 0, 0 );
boxMajTicks = new QComboBox();
ticksLayout->addWidget( boxMajTicks, 0, 1 );
lblMajTicksLength = new QLabel();
ticksLayout->addWidget( lblMajTicksLength, 0, 2 );
boxMajTicksLength = new QSpinBox();
boxMajTicksLength->setRange(0, 100);
boxMajTicksLength->setValue(app->majTicksLength);
ticksLayout->addWidget( boxMajTicksLength, 0, 3 );
lblMinTicks = new QLabel();
ticksLayout->addWidget( lblMinTicks, 1, 0 );
boxMinTicks = new QComboBox();
ticksLayout->addWidget( boxMinTicks, 1, 1 );
lblMinTicksLength = new QLabel();
ticksLayout->addWidget( lblMinTicksLength, 1, 2 );
boxMinTicksLength = new QSpinBox();
boxMinTicksLength->setRange(0, 100);
boxMinTicksLength->setValue(app->minTicksLength);
ticksLayout->addWidget( boxMinTicksLength, 1, 3 );
ticksLayout->setRowStretch( 4, 1 );
plotsTabWidget->addTab( plotTicks, QString() );
plotFonts = new QWidget();
QVBoxLayout * plotFontsLayout = new QVBoxLayout( plotFonts );
QGroupBox * groupBox2DFonts = new QGroupBox();
plotFontsLayout->addWidget( groupBox2DFonts );
QVBoxLayout * fontsLayout = new QVBoxLayout( groupBox2DFonts );
buttonTitleFont= new QPushButton();
fontsLayout->addWidget( buttonTitleFont );
buttonLegendFont= new QPushButton();
fontsLayout->addWidget( buttonLegendFont );
buttonAxesFont= new QPushButton();
fontsLayout->addWidget( buttonAxesFont );
buttonNumbersFont= new QPushButton();
fontsLayout->addWidget( buttonNumbersFont );
fontsLayout->addStretch();
plotsTabWidget->addTab( plotFonts, QString() );
plotPrint = new QWidget();
QVBoxLayout *printLayout = new QVBoxLayout( plotPrint );
boxScaleLayersOnPrint = new QCheckBox();
boxScaleLayersOnPrint->setChecked(app->d_scale_plots_on_print);
printLayout->addWidget( boxScaleLayersOnPrint );
boxPrintCropmarks = new QCheckBox();
boxPrintCropmarks->setChecked(app->d_print_cropmarks);
printLayout->addWidget( boxPrintCropmarks );
printLayout->addStretch();
plotsTabWidget->addTab(plotPrint, QString());
connect( boxResize, SIGNAL( clicked() ), this, SLOT( enableScaleFonts() ) );
connect( boxFrame, SIGNAL( toggled(bool) ), this, SLOT( showFrameWidth(bool) ) );
connect( buttonAxesFont, SIGNAL( clicked() ), this, SLOT( pickAxesFont() ) );
connect( buttonNumbersFont, SIGNAL( clicked() ), this, SLOT( pickNumbersFont() ) );
connect( buttonLegendFont, SIGNAL( clicked() ), this, SLOT( pickLegendFont() ) );
connect( buttonTitleFont, SIGNAL( clicked() ), this, SLOT( pickTitleFont() ) );
if(boxResize->isChecked())
boxScaleFonts->setEnabled(false);
else
boxScaleFonts->setEnabled(true);
if (!ok)
{
boxFrameWidth->hide();
labelFrameWidth->hide();
}
else
{
boxFrameWidth->show();
labelFrameWidth->show();
}
ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(this->parentWidget());
if (!app) {
throw std::logic_error("Parent of ConfigDialog is not ApplicationWindow as expected.");
}
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
plots3D = new QWidget();
QGroupBox * topBox = new QGroupBox();
QGridLayout * topLayout = new QGridLayout( topBox );
topLayout->setSpacing(5);
lblResolution = new QLabel();
topLayout->addWidget( lblResolution, 0, 0 );
boxResolution = new QSpinBox();
boxResolution->setRange(1, 100);
boxResolution->setValue(app->plot3DResolution);
topLayout->addWidget( boxResolution, 0, 1 );
boxShowLegend = new QCheckBox();
boxShowLegend->setChecked(app->showPlot3DLegend);
topLayout->addWidget( boxShowLegend, 1, 0 );
boxShowProjection = new QCheckBox();
boxShowProjection->setChecked(app->showPlot3DProjection);
topLayout->addWidget( boxShowProjection, 1, 1 );
boxSmoothMesh = new QCheckBox();
boxSmoothMesh->setChecked(app->smooth3DMesh);
topLayout->addWidget( boxSmoothMesh, 2, 0 );
boxOrthogonal = new QCheckBox();
boxOrthogonal->setChecked(app->orthogonal3DPlots);
topLayout->addWidget( boxOrthogonal, 2, 1 );
boxAutoscale3DPlots = new QCheckBox();
boxAutoscale3DPlots->setChecked(app->autoscale3DPlots);
topLayout->addWidget( boxAutoscale3DPlots, 3, 0 );
groupBox3DCol = new QGroupBox();
QGridLayout * middleLayout = new QGridLayout( groupBox3DCol );
QStringList plot3DColors = app->plot3DColors;
btnFromColor = new ColorButton();
btnFromColor->setColor(QColor(plot3DColors[4]));
middleLayout->addWidget( btnFromColor, 0, 0 );
btnLabels = new ColorButton();
btnLabels->setColor(QColor(plot3DColors[1]));
middleLayout->addWidget( btnLabels, 0, 1 );
btnMesh = new ColorButton();
btnMesh->setColor(QColor(plot3DColors[2]));
middleLayout->addWidget( btnMesh, 0, 2 );
btnGrid = new ColorButton();
btnGrid->setColor(QColor(plot3DColors[3]));
middleLayout->addWidget( btnGrid, 0, 3 );
btnToColor = new ColorButton();
btnToColor->setColor(QColor(plot3DColors[0]));
middleLayout->addWidget( btnToColor, 1, 0 );
btnNumbers = new ColorButton();
btnNumbers->setColor(QColor(plot3DColors[5]));
middleLayout->addWidget( btnNumbers, 1, 1 );
btnAxes = new ColorButton();
btnAxes->setColor(QColor(plot3DColors[6]));
middleLayout->addWidget( btnAxes, 1, 2 );
btnBackground3D = new ColorButton();
btnBackground3D->setColor(QColor(plot3DColors[7]));
middleLayout->addWidget( btnBackground3D, 1, 3 );
groupBox3DFonts = new QGroupBox();
QHBoxLayout * bottomLayout = new QHBoxLayout( groupBox3DFonts );
btnTitleFnt = new QPushButton();
bottomLayout->addWidget( btnTitleFnt );
btnLabelsFnt = new QPushButton();
bottomLayout->addWidget( btnLabelsFnt );
btnNumFnt = new QPushButton();
bottomLayout->addWidget( btnNumFnt );
QVBoxLayout * plots3DPageLayout = new QVBoxLayout( plots3D );
plots3DPageLayout->addWidget(topBox);
plots3DPageLayout->addWidget(groupBox3DCol);
plots3DPageLayout->addWidget(groupBox3DFonts);
plots3DPageLayout->addStretch();
connect( btnNumFnt, SIGNAL( clicked() ), this, SLOT(pick3DNumbersFont() ) );
connect( btnTitleFnt, SIGNAL( clicked() ), this, SLOT(pick3DTitleFont() ) );
connect( btnLabelsFnt, SIGNAL( clicked() ), this, SLOT(pick3DAxesFont() ) );
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(this->parentWidget());
appTabWidget = new QTabWidget(generalDialog);
appTabWidget->setUsesScrollButtons(false);
application = new QWidget();
QVBoxLayout * applicationLayout = new QVBoxLayout( application );
QGroupBox * groupBoxApp = new QGroupBox();
applicationLayout->addWidget(groupBoxApp);
QGridLayout * topBoxLayout = new QGridLayout( groupBoxApp );
lblLanguage = new QLabel();
topBoxLayout->addWidget( lblLanguage, 0, 0 );
boxLanguage = new QComboBox();
insertLanguagesList();
topBoxLayout->addWidget( boxLanguage, 0, 1 );
lblStyle = new QLabel();
topBoxLayout->addWidget( lblStyle, 1, 0 );
boxStyle = new QComboBox();
topBoxLayout->addWidget( boxStyle, 1, 1 );
QStringList styles = QStyleFactory::keys();
styles.sort();
boxStyle->addItems(styles);
boxStyle->setCurrentIndex(boxStyle->findText(app->appStyle,Qt::MatchWildcard));
lblFonts = new QLabel();
topBoxLayout->addWidget( lblFonts, 2, 0 );
fontsBtn= new QPushButton();
topBoxLayout->addWidget( fontsBtn, 2, 1 );
lblScriptingLanguage = new QLabel();
topBoxLayout->addWidget( lblScriptingLanguage, 3, 0 );
boxScriptingLanguage = new QComboBox();
QStringList llist = ScriptingLangManager::languages();
boxScriptingLanguage->insertStringList(llist);
boxScriptingLanguage->setCurrentItem(llist.findIndex(app->defaultScriptingLang));
topBoxLayout->addWidget( boxScriptingLanguage, 3, 1 );
lblUndoStackSize = new QLabel();
topBoxLayout->addWidget( lblUndoStackSize, 4, 0 );
undoStackSizeBox = new QSpinBox();
undoStackSizeBox->setValue(app->matrixUndoStackSize());
topBoxLayout->addWidget( undoStackSizeBox, 4, 1 );
lblEndOfLine = new QLabel();
topBoxLayout->addWidget(lblEndOfLine, 5, 0 );
boxEndLine = new QComboBox();
boxEndLine->addItem(tr("LF (Unix)"));
boxEndLine->addItem(tr("CRLF (Windows)"));
boxEndLine->addItem(tr("CR (Mac)"));
boxEndLine->setCurrentIndex((int)app->d_eol);
topBoxLayout->addWidget(boxEndLine, 5, 1);
lblInitWindow = new QLabel();
topBoxLayout->addWidget( lblInitWindow, 6, 0 );
boxInitWindow = new QComboBox();
topBoxLayout->addWidget( boxInitWindow, 6, 1 );
boxSave= new QCheckBox();
boxSave->setChecked(app->autoSave);
topBoxLayout->addWidget( boxSave, 7, 0 );
boxMinutes = new QSpinBox();
boxMinutes->setRange(1, 100);
boxMinutes->setValue(app->autoSaveTime);
boxMinutes->setEnabled(app->autoSave);
topBoxLayout->addWidget( boxMinutes, 7, 1 );
boxBackupProject = new QCheckBox();
boxBackupProject->setChecked(app->d_backup_files);
topBoxLayout->addWidget( boxBackupProject, 8, 0, 1, 2 );
boxSearchUpdates = new QCheckBox();
boxSearchUpdates->setChecked(app->autoSearchUpdates);
topBoxLayout->addWidget( boxSearchUpdates, 9, 0, 1, 2 );
topBoxLayout->setRowStretch(10, 1);
appTabWidget->addTab(application, QString());
appTabWidget->addTab( confirm, QString() );
appColors = new QWidget();
QVBoxLayout * appColorsLayout = new QVBoxLayout( appColors );
QGroupBox * groupBoxAppCol = new QGroupBox();
appColorsLayout->addWidget( groupBoxAppCol );
QGridLayout * colorsBoxLayout = new QGridLayout( groupBoxAppCol );
lblWorkspace = new QLabel();
colorsBoxLayout->addWidget( lblWorkspace, 0, 0 );
btnWorkspace = new ColorButton();
btnWorkspace->setColor(app->workspaceColor);
colorsBoxLayout->addWidget( btnWorkspace, 0, 1 );
lblPanels = new QLabel();
colorsBoxLayout->addWidget( lblPanels, 1, 0 );
btnPanels = new ColorButton();
colorsBoxLayout->addWidget( btnPanels, 1, 1 );
btnPanels->setColor(app->panelsColor);
lblPanelsText = new QLabel();
colorsBoxLayout->addWidget( lblPanelsText, 2, 0 );
btnPanelsText = new ColorButton();
colorsBoxLayout->addWidget( btnPanelsText, 2, 1 );
btnPanelsText->setColor(app->panelsTextColor);
colorsBoxLayout->setRowStretch( 3, 1 );
appTabWidget->addTab( appColors, QString() );
numericFormatPage = new QWidget();
QVBoxLayout *numLayout = new QVBoxLayout( numericFormatPage );
QGroupBox *numericFormatBox = new QGroupBox();
numLayout->addWidget( numericFormatBox );
QGridLayout *numericFormatLayout = new QGridLayout( numericFormatBox );
lblAppPrecision = new QLabel();
numericFormatLayout->addWidget(lblAppPrecision, 0, 0);
boxAppPrecision = new QSpinBox();
boxAppPrecision->setRange(0, 14);
boxAppPrecision->setValue(app->d_decimal_digits);
numericFormatLayout->addWidget(boxAppPrecision, 0, 1);
lblDecimalSeparator = new QLabel();
numericFormatLayout->addWidget(lblDecimalSeparator, 1, 0 );
boxDecimalSeparator = new QComboBox();
boxDecimalSeparator->addItem(tr("System Locale Setting"));
boxDecimalSeparator->addItem("1,000.0");
boxDecimalSeparator->addItem("1.000,0");
boxDecimalSeparator->addItem("1 000,0");
numericFormatLayout->addWidget(boxDecimalSeparator, 1, 1);
boxThousandsSeparator = new QCheckBox();
boxThousandsSeparator->setChecked(app->locale().numberOptions() & QLocale::OmitGroupSeparator);
numericFormatLayout->addWidget(boxThousandsSeparator, 2, 0);
boxUpdateSeparators = new QCheckBox();
boxUpdateSeparators->setChecked(true);
numericFormatLayout->addWidget(boxUpdateSeparators, 3, 0);
numericFormatLayout->setRowStretch(4, 1);
appTabWidget->addTab( numericFormatPage, QString() );
// Floating windows page
floatingWindowsPage = new QWidget();
QVBoxLayout *floatLayout = new QVBoxLayout(floatingWindowsPage);
QGroupBox *floatBox = new QGroupBox();
floatLayout->addWidget(floatBox);
QGridLayout *floatPageLayout = new QGridLayout(floatBox);
QLabel* comment = new QLabel("Select types of windows to be floating by default.\n"
"You can use Windows menu to make a window floating or docked.");
floatPageLayout->addWidget(comment,0,0);
boxFloatingGraph = new QCheckBox("Graphs"); // default to true
boxFloatingGraph->setChecked(app->isDefaultFloating("MultiLayer"));
floatPageLayout->addWidget(boxFloatingGraph,1,0);
boxFloatingTable = new QCheckBox("Tables");
boxFloatingTable->setChecked(app->isDefaultFloating("Table"));
floatPageLayout->addWidget(boxFloatingTable,2,0);
boxFloatingInstrumentWindow = new QCheckBox("Instrument views"); // default to true
boxFloatingInstrumentWindow->setChecked(app->isDefaultFloating("InstrumentWindow"));
floatPageLayout->addWidget(boxFloatingInstrumentWindow,3,0);
boxFloatingMantidMatrix = new QCheckBox("Mantid Matrices");
boxFloatingMantidMatrix->setChecked(app->isDefaultFloating("MantidMatrix"));
floatPageLayout->addWidget(boxFloatingMantidMatrix,4,0);
boxFloatingNote = new QCheckBox("Notes");
boxFloatingNote->setChecked(app->isDefaultFloating("Note"));
floatPageLayout->addWidget(boxFloatingNote,5,0);
boxFloatingMatrix = new QCheckBox("Matrices");
boxFloatingMatrix->setChecked(app->isDefaultFloating("Matrix"));
floatPageLayout->addWidget(boxFloatingMatrix,6,0);
boxFloatingCustomInterfaces = new QCheckBox("Custom interfaces");
boxFloatingCustomInterfaces->setChecked(app->isDefaultFloating("MdiSubWindow"));
floatPageLayout->addWidget(boxFloatingCustomInterfaces,7,0);
boxFloatingTiledWindows = new QCheckBox("Tiled Windows");
boxFloatingTiledWindows->setChecked(app->isDefaultFloating("TiledWindow"));
floatPageLayout->addWidget(boxFloatingTiledWindows,8,0);
floatPageLayout->setRowStretch(8,1);
appTabWidget->addTab(floatingWindowsPage, QString());
connect( boxLanguage, SIGNAL( activated(int) ), this, SLOT( switchToLanguage(int) ) );
connect( fontsBtn, SIGNAL( clicked() ), this, SLOT( pickApplicationFont() ) );
connect( boxSave, SIGNAL( toggled(bool) ), boxMinutes, SLOT( setEnabled(bool) ) );
Gigg, Martyn Anthony
committed
/**
* Configure a Mantid page on the config dialog
*/
Gigg, Martyn Anthony
committed
void ConfigDialog::initMantidPage()
{
mtdTabWidget = new QTabWidget(generalDialog);
mtdTabWidget->setUsesScrollButtons(false);
Gigg, Martyn Anthony
committed
instrumentPage = new QWidget();
QVBoxLayout *instrTabLayout = new QVBoxLayout(instrumentPage);
Gigg, Martyn Anthony
committed
QGroupBox *frame = new QGroupBox();
instrTabLayout->addWidget(frame);
QGridLayout *grid = new QGridLayout(frame);
Gigg, Martyn Anthony
committed
mtdTabWidget->addTab(instrumentPage, QString());
Gigg, Martyn Anthony
committed
facility = new QComboBox();
grid->addWidget(new QLabel("Facility"), 0, 0);
grid->addWidget(facility, 0, 1);
Gigg, Martyn Anthony
committed
defInstr = new MantidQt::MantidWidgets::InstrumentSelector();
// Here we only want the default instrument updated if the user clicks Ok/Apply
defInstr->updateInstrumentOnSelection(false);
Gigg, Martyn Anthony
committed
grid->addWidget(new QLabel("Default Instrument"), 2, 0);
grid->addWidget(defInstr, 2, 1);
Gigg, Martyn Anthony
committed
grid->setRowStretch(3,1);
//Ignore paraview.
ckIgnoreParaView = new QCheckBox("Ignore ParaView");
ckIgnoreParaView->setToolTip("Don't bother me with anything to do with ParaView.\nRequires restart of MantidPlot to take effect.");
auto& cfgSvc = ConfigService::Instance();
const std::string ignoreParaViewProperty = "paraview.ignore";
bool ignoreParaView = cfgSvc.hasProperty(ignoreParaViewProperty) && bool(atoi(cfgSvc.getString(ignoreParaViewProperty).c_str()));
ckIgnoreParaView->setChecked(ignoreParaView);
grid->addWidget(ckIgnoreParaView, 3, 0);
Gigg, Martyn Anthony
committed
// Populate boxes
auto faclist = cfgSvc.getFacilityNames();
for ( auto it = faclist.begin(); it != faclist.end(); ++it )
{
facility->addItem(QString::fromStdString(*it));
}
Gigg, Martyn Anthony
committed
// Set default property
QString property = QString::fromStdString( cfgSvc.getFacility().name());
Gigg, Martyn Anthony
committed
int index = facility->findText(property);
if( index < 0 )
{
index = 0;
}
Gigg, Martyn Anthony
committed
facility->setCurrentIndex(index);
Gigg, Martyn Anthony
committed
// Ensure update of instrument box with facility change
connect(facility, SIGNAL(currentIndexChanged(const QString&)), defInstr, SLOT(fillWithInstrumentsFromFacility(const QString &)));
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
initDirSearchTab();
initCurveFittingTab();
Robert Whitley
committed
initSendToProgramTab();
initMantidOptionsTab();
}
/**
* Configure a MD Plotting Page
*/
void ConfigDialog::initMdPlottingPage()
{
mdPlottingTabWidget = new QTabWidget(generalDialog);
mdPlottingTabWidget->setUsesScrollButtons(false);
// General MD Plotting tab
initMdPlottingGeneralTab();
// VSI tab
initMdPlottingVsiTab();
// Set the connections
setupMdPlottingConnections();
// Update the visibility of the Vsi tab if the General Md Color Map was selected the last time
if (m_mdSettings.getUsageGeneralMdColorMap())
changeUsageGeneralMdColorMap();
// Update the visibility of the Vsi tab if the last session checkbox was selected.
if (m_mdSettings.getUsageLastSession())
{
changeUsageLastSession();
}
/**
* Configure the general MD Plotting tab
*/
void ConfigDialog::initMdPlottingGeneralTab()
{
// Ask if uniform colormap
mdPlottingGeneralPage = new QWidget();
QVBoxLayout *generalTabLayout = new QVBoxLayout(mdPlottingGeneralPage);
mdPlottingGeneralFrame = new QGroupBox(mdPlottingGeneralPage);
generalTabLayout->addWidget(mdPlottingGeneralFrame );
mdPlottingTabWidget->addTab(mdPlottingGeneralPage, QString());
// Color Map
mdPlottingGeneralFrame->setCheckable(true);
mdPlottingGeneralFrame->setChecked(m_mdSettings.getUsageGeneralMdColorMap());
QGridLayout *gridVsiGeneralDefaultColorMap = new QGridLayout(mdPlottingGeneralFrame);
mdPlottingGeneralColorMap = new QComboBox();
lblGeneralDefaultColorMap = new QLabel();
gridVsiGeneralDefaultColorMap->addWidget(lblGeneralDefaultColorMap, 1, 0);
gridVsiGeneralDefaultColorMap->addWidget(mdPlottingGeneralColorMap, 1, 1);
gridVsiGeneralDefaultColorMap->setRowStretch(2,1);
QLabel* label = new QLabel("<span style=\"font-weight:600;\">Note: Changes will not take effect until MantidPlot has been restarted.</span>");
generalTabLayout->addWidget(label);
// Set the color maps
MantidQt::API::MdPlottingCmapsProvider mdPlottingCmapsProvider;
QStringList colorMapNames;
QStringList colorMapFiles;
mdPlottingCmapsProvider.getColorMapsForMdPlotting(colorMapNames, colorMapFiles);
if (colorMapNames.size() == colorMapFiles.size())
{
for (int index = 0; index < colorMapNames.size(); ++index)
{
mdPlottingGeneralColorMap->addItem(colorMapNames[index], colorMapFiles[index]);
}
}
int currentIndex = mdPlottingGeneralColorMap->findData(m_mdSettings.getGeneralMdColorMapName(), Qt::DisplayRole);
if (currentIndex != -1)
{
mdPlottingGeneralColorMap->setCurrentIndex(currentIndex);
}
}
/**
* Configure the VSI tab
*/
void ConfigDialog::initMdPlottingVsiTab()
{
vsiPage = new QWidget();
QVBoxLayout *vsiTabLayout = new QVBoxLayout(vsiPage);
// Initial View when loading into the VSI
QGroupBox *frameTop = new QGroupBox();
vsiTabLayout->addWidget(frameTop);
QGridLayout *gridTop = new QGridLayout(frameTop);
vsiInitialView = new QComboBox();
lblVsiInitialView = new QLabel();
gridTop->addWidget(lblVsiInitialView, 0, 0);
gridTop->addWidget(vsiInitialView, 0, 1);
mdPlottingVsiFrameBottom = new QGroupBox();
mdPlottingVsiFrameBottom->setCheckable(true);
mdPlottingVsiFrameBottom->setChecked(!m_mdSettings.getUsageLastSession());
vsiTabLayout->addWidget(mdPlottingVsiFrameBottom);
QGridLayout *grid = new QGridLayout(mdPlottingVsiFrameBottom);
mdPlottingTabWidget->addTab(vsiPage, QString());
// Color Map
vsiDefaultColorMap = new QComboBox();
lblVsiDefaultColorMap = new QLabel();
grid->addWidget(lblVsiDefaultColorMap, 0, 0);
grid->addWidget(vsiDefaultColorMap, 0, 1);
// Background Color
vsiDefaultBackground = new ColorButton();
lblVsiDefaultBackground = new QLabel();
grid->addWidget(lblVsiDefaultBackground, 1, 0);
grid->addWidget(vsiDefaultBackground, 1, 1);
const QColor backgroundColor = m_mdSettings.getUserSettingBackgroundColor();
vsiDefaultBackground->setColor(backgroundColor);
grid->setRowStretch(4,1);
QLabel* label1 = new QLabel("<span style=\"font-weight:600;\">Note: The General Tab settings take precedence over the VSI Tab settings.</span>");
vsiTabLayout->addWidget(label1);
QLabel* label2 = new QLabel("<span style=\"font-weight:600;\">Note: Changes will not take effect until the VSI has been restarted.</span>");
vsiTabLayout->addWidget(label2);
// Set the color map selection for the VSI
QStringList maps;
MantidQt::API::MdPlottingCmapsProvider mdPlottingCmapsProvider;
mdPlottingCmapsProvider.getColorMapsForVSI(maps);
MantidQt::API::MdConstants mdConstants;
vsiDefaultColorMap->addItems(mdConstants.getVsiColorMaps());
vsiDefaultColorMap->addItems(maps);
int index = vsiDefaultColorMap->findData(m_mdSettings.getUserSettingColorMap(), Qt::DisplayRole);
if (index != -1)
{
vsiDefaultColorMap->setCurrentIndex(index);
}
// Set the initial view selection for the VSI
QStringList views;
views = mdConstants.getAllInitialViews();
vsiInitialView->addItems(views);
int indexInitialView = vsiInitialView->findData(m_mdSettings.getUserSettingInitialView(), Qt::DisplayRole);
if (indexInitialView != -1)
{
vsiInitialView->setCurrentIndex(indexInitialView);
}
* Set up the connections for Md Plotting
*/
void ConfigDialog::setupMdPlottingConnections()
{
QObject::connect(this->mdPlottingGeneralFrame, SIGNAL(toggled(bool)), this, SLOT(changeUsageGeneralMdColorMap()));
QObject::connect(this->mdPlottingVsiFrameBottom, SIGNAL(toggled(bool)), this, SLOT(changeUsageLastSession()));
}
/**
* Handle a change of the General Md Color Map selection.
*/
void ConfigDialog::changeUsageGeneralMdColorMap()
// If the general color map setting is turned off and the vsi colormap is turned on
// then we set the default color map to enabled, else we disable it
bool isDefaultColorMapSelectable = (!mdPlottingGeneralFrame->isChecked() && mdPlottingVsiFrameBottom->isChecked());
vsiDefaultColorMap->setEnabled(isDefaultColorMapSelectable);
lblVsiDefaultColorMap->setEnabled(isDefaultColorMapSelectable);
//vsiDefaultColorMap->setEnabled(true);
//lblVsiDefaultColorMap->setEnabled(true);
Gigg, Martyn Anthony
committed
/**
* Handle a change of the Last Session selection.
* @param isDefaultColorMapVsiChecked The state of the vsi default checkbox.
void ConfigDialog::changeUsageLastSession()
// Set the color map of the VSI default
changeUsageGeneralMdColorMap();
// Set the visibility of the background color button of the VSI
vsiDefaultBackground->setEnabled(mdPlottingVsiFrameBottom->isChecked());
lblVsiDefaultBackground->setEnabled(mdPlottingVsiFrameBottom->isChecked());
* Configure a Mantid Options page on the config dialog
*/
void ConfigDialog::initMantidOptionsTab()
{
mantidOptionsPage = new QWidget();
mtdTabWidget->addTab(mantidOptionsPage,"Options");
QVBoxLayout *widgetLayout = new QVBoxLayout(mantidOptionsPage);
QGroupBox *frame = new QGroupBox();
widgetLayout->addWidget(frame);
QGridLayout *grid = new QGridLayout(frame);
// if on, for example all plotSpectrum will go to the same window.
m_reusePlotInstances = new QCheckBox("Re-use plot instances for different types of plots");
m_reusePlotInstances->setChecked(false);
grid->addWidget(m_reusePlotInstances,0,0);
QString setting = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("MantidOptions.ReusePlotInstances"));
if(!setting.compare("On"))
{
m_reusePlotInstances->setChecked(true);
}
else if(!setting.compare("Off"))
{
m_reusePlotInstances->setChecked(false);
}
m_reusePlotInstances->setToolTip("If on, the same plot instance will be re-used for every of the different plots available in the workspaces window (spectrum, slice, color fill, etc.)");
//create a checkbox for invisible workspaces options
m_invisibleWorkspaces = new QCheckBox("Show Invisible Workspaces");
Sofia Antony
committed
m_invisibleWorkspaces->setChecked(false);
grid->addWidget(m_invisibleWorkspaces,1,0);
setting = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("MantidOptions.InvisibleWorkspaces"));
if(!setting.compare("1"))
{
m_invisibleWorkspaces->setChecked(true);
}
else if(!setting.compare("0"))
{
m_invisibleWorkspaces->setChecked(false);
}
//categories tree widget
treeCategories = new QTreeWidget(frame);
treeCategories->setColumnCount(1);
treeCategories->setSortingEnabled(false);
treeCategories->setHeaderLabel("Show Algorithm Categories");
grid->addWidget(treeCategories,2,0);
// create a checkbox for the instrument view OpenGL option
m_useOpenGL = new QCheckBox("Use OpenGL in Instrument View");
m_useOpenGL->setChecked(true);
grid->addWidget(m_useOpenGL,4,0);
setting = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().
getString("MantidOptions.InstrumentView.UseOpenGL")).toUpper();
if( setting == "ON")
{
m_useOpenGL->setChecked(true);
}
else
{
m_useOpenGL->setChecked(false);
}
Robert Whitley
committed
void ConfigDialog::initSendToProgramTab()
{
mantidSendToPage = new QWidget();
mtdTabWidget->addTab(mantidSendToPage, tr("Send To"));
QVBoxLayout *widgetLayout = new QVBoxLayout(mantidSendToPage);
QGroupBox *frame = new QGroupBox();
widgetLayout ->addWidget(frame);
QGridLayout *grid = new QGridLayout(frame);
Robert Whitley
committed
//Add buttons to the bottom of the widget
deleteButton = new QPushButton(tr("Delete"));
deleteButton->setEnabled(false);
connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteDialog()));
Robert Whitley
committed
editButton = new QPushButton(tr("Edit..."));
editButton->setEnabled(false);
connect(editButton, SIGNAL(clicked()), this, SLOT(editDialog()));
addButton = new QPushButton(tr("Add..."));
connect(addButton, SIGNAL(clicked()), this, SLOT(addDialog()));