Skip to content

Commit

Permalink
Prefs: add help button
Browse files Browse the repository at this point in the history
  • Loading branch information
olear committed May 3, 2016
1 parent b730225 commit 14538f4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Gui/PreferencesPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CLANG_DIAG_OFF(uninitialized)
#include <QApplication>
#include <QDialogButtonBox>
#include <QKeyEvent>
#include <QDesktopServices>
CLANG_DIAG_ON(deprecated)
CLANG_DIAG_ON(uninitialized)

Expand Down Expand Up @@ -69,18 +70,24 @@ PreferencesPanel::PreferencesPanel(boost::shared_ptr<Settings> settings,
_buttonBox = new QDialogButtonBox(Qt::Horizontal);
_restoreDefaultsB = new Button( tr("Restore defaults") );
_restoreDefaultsB->setToolTip( GuiUtils::convertFromPlainText(tr("Restore default values for all preferences."), Qt::WhiteSpaceNormal) );

_prefsHelp = new Button( tr("Help") );
_prefsHelp->setToolTip( tr("Show help for preference") );

_cancelB = new Button( tr("Discard") );
_cancelB->setToolTip( GuiUtils::convertFromPlainText(tr("Cancel changes that were not saved and close the window."), Qt::WhiteSpaceNormal) );
_okB = new Button( tr("Save") );
_okB->setToolTip( GuiUtils::convertFromPlainText(tr("Save changes on disk and close the window."), Qt::WhiteSpaceNormal) );
_buttonBox->addButton(_restoreDefaultsB, QDialogButtonBox::ResetRole);
_buttonBox->addButton(_prefsHelp, QDialogButtonBox::ResetRole);
_buttonBox->addButton(_cancelB, QDialogButtonBox::RejectRole);
_buttonBox->addButton(_okB, QDialogButtonBox::AcceptRole);

// _mainLayout->addStretch();
_mainLayout->addWidget(_buttonBox);

QObject::connect( _restoreDefaultsB, SIGNAL(clicked()), this, SLOT(restoreDefaults()) );
QObject::connect( _prefsHelp, SIGNAL(clicked()), this, SLOT(openHelp()) );
QObject::connect( _buttonBox, SIGNAL(rejected()), this, SLOT(cancelChanges()) );
QObject::connect( _buttonBox, SIGNAL(accepted()), this, SLOT(saveChangesAndClose()) );
QObject::connect( _settings.get(), SIGNAL(settingChanged(KnobI*)), this, SLOT(onSettingChanged(KnobI*)) );
Expand All @@ -101,6 +108,26 @@ PreferencesPanel::onSettingChanged(KnobI* knob)
_changedKnobs.push_back(knob);
}

void PreferencesPanel::openHelp()
{
int docSource = appPTR->getCurrentSettings()->getDocumentationSource();
int serverPort = appPTR->getCurrentSettings()->getServerPort();
QString localUrl = QString::fromUtf8("http://localhost:") + QString::number(serverPort) + QString::fromUtf8("/_prefs.html");
QString remoteUrl = QString::fromUtf8(NATRON_DOCUMENTATION_ONLINE);

switch (docSource) {
case 0:
QDesktopServices::openUrl( QUrl(localUrl) );
break;
case 1:
QDesktopServices::openUrl( QUrl(remoteUrl) );
break;
case 2:
Dialogs::informationDialog(tr("Missing documentation").toStdString(), QObject::tr("Missing documentation, please go to settings and select local or online documentation source.").toStdString(), true);
break;
}
}

void
PreferencesPanel::restoreDefaults()
{
Expand Down
3 changes: 3 additions & 0 deletions Gui/PreferencesPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public Q_SLOTS:

void onSettingChanged(KnobI* knob);

void openHelp();

private:

virtual void showEvent(QShowEvent* e) OVERRIDE;
Expand All @@ -77,6 +79,7 @@ public Q_SLOTS:
DockablePanel* _panel;
QDialogButtonBox* _buttonBox;
Button* _restoreDefaultsB;
Button* _prefsHelp;
Button* _cancelB;
Button* _okB;
boost::shared_ptr<Settings> _settings;
Expand Down

0 comments on commit 14538f4

Please sign in to comment.