Skip to content

Commit

Permalink
SequenceFileDialog: simpler GUI + fix font issues
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Jan 24, 2017
1 parent 24762ea commit 6d43554
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 121 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This is a bug-fix release
- fix hue display in the viewer #1554
- EdgeBlur now has an optional Matte input used to compute the edges #1553
- fix reading image sequences that do not have frame number 1 in them #1556
- better/simpler GUI and documentation for the file dialog.

## Version 2.2.1

Expand Down
1 change: 0 additions & 1 deletion Gui/EditExpressionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON
#include <QGroupBox>
#include <QtGui/QVector4D>
#include <QStyleFactory>
#include <QComboBox>
#include <QCompleter>

#include "Global/GlobalDefines.h"
Expand Down
1 change: 0 additions & 1 deletion Gui/EditScriptDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON
#include <QGroupBox>
#include <QtGui/QVector4D>
#include <QStyleFactory>
#include <QComboBox>
#include <QCompleter>

#include "Global/GlobalDefines.h"
Expand Down
6 changes: 5 additions & 1 deletion Gui/Gui20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ Gui::loadStyleSheet()
if ( qss.open(QIODevice::ReadOnly
| QIODevice::Text) ) {
QTextStream in(&qss);
QString content = QString::fromUtf8("QWidget { font-family: \"%1\"; font-size: %2pt; }\n").arg(appPTR->getAppFont()).arg(appPTR->getAppFontSize());
QString content = QString::fromUtf8("QWidget { font-family: \"%1\"; font-size: %2pt; }\n"
"QListView { font-family: \"%1\"; font-size: %2pt; }\n" // .. or the items in the QListView get the wrong font
"QComboBox::drop-down { font-family: \"%1\"; font-size: %2pt; }\n" // ... or the drop-down doesn't get the right font
"QInputDialog { font-family: \"%1\"; font-size: %2pt; }\n" // ... or the label doesn't get the right font
).arg(appFont).arg(appFontSize);
content += in.readAll();
qApp->setStyleSheet( content
.arg( qcolor_to_qstring(selCol) ) // %1: selection-color
Expand Down
1 change: 0 additions & 1 deletion Gui/Gui50.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON
#include <QLineEdit>
#include <QCursor>
#include <QCheckBox>
#include <QComboBox>
#include <QTreeView>

#include "Global/QtCompat.h"
Expand Down
1 change: 0 additions & 1 deletion Gui/LinkToKnobDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON
#include <QGroupBox>
#include <QtGui/QVector4D>
#include <QStyleFactory>
#include <QComboBox>
#include <QCompleter>

#include "Global/GlobalDefines.h"
Expand Down
133 changes: 53 additions & 80 deletions Gui/SequenceFileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CLANG_DIAG_OFF(uninitialized)
#include <QCheckBox>
#include <QFileIconProvider>
#include <QFileSystemModel>
#include <QInputDialog>
//#include <QInputDialog>
#include <QSplitter>
#include <QtGui/QIcon>
#include <QDialog>
Expand Down Expand Up @@ -92,6 +92,7 @@ CLANG_DIAG_ON(uninitialized)
#include "Engine/MemoryInfo.h" // printAsRAM
#include "Engine/Node.h"
#include "Engine/Project.h"
#include "Engine/PyParameter.h" // StringParam
#include "Engine/Settings.h"
#include "Engine/Utils.h" // convertFromPlainText
#include "Engine/ViewerInstance.h"
Expand All @@ -102,8 +103,9 @@ CLANG_DIAG_ON(uninitialized)
#include "Gui/DialogButtonBox.h"
#include "Gui/GuiApplicationManager.h"
#include "Gui/Gui.h"
#include "Gui/NodeGui.h"
#include "Gui/GuiAppInstance.h"
#include "Gui/NodeGui.h"
#include "Gui/PythonPanels.h"
#include "Gui/ViewerTab.h"
#include "Gui/ViewerGL.h"
#include "Gui/TabWidget.h"
Expand Down Expand Up @@ -292,24 +294,28 @@ SequenceFileDialog::SequenceFileDialog( QWidget* parent, // necessary to transmi
_previousButton = new Button(style()->standardIcon(QStyle::SP_ArrowBack), QString(), _buttonsWidget);
_previousButton->setFixedSize(buttonSize);
_previousButton->setIconSize(buttonIconSize);
_previousButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Go back in the directory history."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_buttonsLayout->addWidget(_previousButton);
QObject::connect( _previousButton, SIGNAL(clicked()), this, SLOT(previousFolder()) );

_nextButton = new Button(style()->standardIcon(QStyle::SP_ArrowForward), QString(), _buttonsWidget);
_nextButton->setFixedSize(buttonSize);
_nextButton->setIconSize(buttonIconSize);
_nextButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Go forward in the directory history."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_buttonsLayout->addWidget(_nextButton);
QObject::connect( _nextButton, SIGNAL(clicked()), this, SLOT(nextFolder()) );

_upButton = new Button(style()->standardIcon(QStyle::SP_ArrowUp), QString(), _buttonsWidget);
_upButton->setIconSize(buttonIconSize);
_upButton->setFixedSize(buttonSize);
_upButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Go to the parent directory."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_buttonsLayout->addWidget(_upButton);
QObject::connect( _upButton, SIGNAL(clicked()), this, SLOT(parentFolder()) );

_createDirButton = new Button(style()->standardIcon(QStyle::SP_FileDialogNewFolder), QString(), _buttonsWidget);
_createDirButton->setIconSize(buttonIconSize);
_createDirButton->setFixedSize(buttonSize);
_createDirButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Create a new directory here."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_buttonsLayout->addWidget(_createDirButton);
QObject::connect( _createDirButton, SIGNAL(clicked()), this, SLOT(createDir()) );

Expand Down Expand Up @@ -337,13 +343,21 @@ SequenceFileDialog::SequenceFileDialog( QWidget* parent, // necessary to transmi
_favoriteButtonsLayout->setContentsMargins(0, 0, 0, 0);
_favoriteButtonsWidget->setLayout(_favoriteButtonsLayout);

_addFavoriteButton = new Button(QString::fromUtf8("+"), this);
_addFavoriteButton = new Button(QString::fromUtf8(" + "), this);
_addFavoriteButton->setMaximumSize(20, 20);
_addFavoriteButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Add the current directory to the favorites list."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_favoriteButtonsLayout->addWidget(_addFavoriteButton);
QObject::connect( _addFavoriteButton, SIGNAL(clicked()), this, SLOT(addFavorite()) );

_removeFavoriteButton = new Button(QString::fromUtf8("-"), this);
// we don't need an editor: just romove favorite and add a new one
//_editFavoriteButton = new Button(tr("Edit"), this);
//_editFavoriteButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Edit the selected favorite."), NATRON_NAMESPACE::WhiteSpaceNormal) );
//_favoriteButtonsLayout->addWidget(_editFavoriteButton);
//QObject::connect( _editFavoriteButton, SIGNAL(clicked()), this, SLOT(editUrl()) );

_removeFavoriteButton = new Button(QString::fromUtf8(" - "), this);
_removeFavoriteButton->setMaximumSize(20, 20);
_removeFavoriteButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Remove the selected directory from the favorites list."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_favoriteButtonsLayout->addWidget(_removeFavoriteButton);
QObject::connect( _removeFavoriteButton, SIGNAL(clicked()), _favoriteView, SLOT(removeEntry()) );

Expand All @@ -365,7 +379,7 @@ SequenceFileDialog::SequenceFileDialog( QWidget* parent, // necessary to transmi

_relativeChoice = new ComboBox(_selectionWidget);
QObject::connect( _relativeChoice, SIGNAL(currentIndexChanged(int)), this, SLOT(onRelativeChoiceChanged(int)) );
_relativeChoice->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("This controls how the file-path (absolute/relative) that you choose will be fetched once you have " "chosen a file. The path will be made relative to the selected project path only when OK will be pressed."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_relativeChoice->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("This controls how the selected file path is referred to. It can be either Absolute, or relative to one of the project paths. Note that the [Project] path exists only once the project is saved, so it is best to save an empty project before opening any external file."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_selectionLayout->addWidget(_relativeChoice);
_relativeChoice->addItem( tr("Absolute") );
std::map<std::string, std::string> projectPaths;
Expand All @@ -386,6 +400,7 @@ SequenceFileDialog::SequenceFileDialog( QWidget* parent, // necessary to transmi
_sequenceButton = new ComboBox(_selectionWidget);
_sequenceButton->addItem( tr("Sequence:") );
_sequenceButton->addItem( tr("File:") );
_sequenceButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Control whether to select a file sequence or a single file."), NATRON_NAMESPACE::WhiteSpaceNormal) );


if (isSequenceDialog) {
Expand Down Expand Up @@ -1108,7 +1123,7 @@ SequenceDialogView::SequenceDialogView(SequenceFileDialog* fd)
setContextMenuPolicy(Qt::CustomContextMenu);
setDragEnabled(true);
setDragDropMode(QAbstractItemView::DragOnly);
//setAttribute(Qt::WA_MacShowFocusRect,0);
setAttribute(Qt::WA_MacShowFocusRect, 0);
setAcceptDrops(true);
}

Expand Down Expand Up @@ -1408,12 +1423,13 @@ void
SequenceFileDialog::createDir()
{
_favoriteView->clearSelection();
QString newFolderString;
QInputDialog dialog(this);
dialog.setLabelText( tr("Folder name:") );

NATRON_PYTHON_NAMESPACE::PyModalDialog dialog(_gui);
dialog.setWindowTitle( tr("New Folder") );
boost::shared_ptr<NATRON_PYTHON_NAMESPACE::StringParam> folderName( dialog.createStringParam( QString::fromUtf8("folderName"), QString::fromUtf8("Folder Name") ) );
dialog.refreshUserParamsGUI();
if ( dialog.exec() ) {
newFolderString = dialog.textValue();
QString newFolderString = folderName->getValue();
if ( !newFolderString.isEmpty() ) {
QString folderName = newFolderString;
QString prefix = currentDirectory().absolutePath();
Expand All @@ -1434,76 +1450,13 @@ SequenceFileDialog::createDir()
}
}

AddFavoriteDialog::AddFavoriteDialog(SequenceFileDialog* fd,
QWidget* parent)
: QDialog(parent)
, _fd(fd)
{
_mainLayout = new QVBoxLayout(this);
_mainLayout->setSpacing(0);
_mainLayout->setContentsMargins(5, 5, 0, 0);
setLayout(_mainLayout);
setWindowTitle( tr("New Favorite") );

_descriptionLabel = new Label(QString(), this);
_mainLayout->addWidget(_descriptionLabel);

_secondLine = new QWidget(this);
_secondLineLayout = new QHBoxLayout(_secondLine);

_pathLineEdit = new LineEdit(_secondLine);
_pathLineEdit->setPlaceholderText( tr("path...") );
_secondLineLayout->addWidget(_pathLineEdit);


QPixmap pix;
appPTR->getIcon(NATRON_PIXMAP_OPEN_FILE, &pix);

_openDirButton = new Button(_secondLine);
_openDirButton->setIcon( QIcon(pix) );
QObject::connect( _openDirButton, SIGNAL(clicked()), this, SLOT(openDir()) );
_secondLineLayout->addWidget(_openDirButton);

_mainLayout->addWidget(_secondLine);

_buttonBox = new DialogButtonBox(QDialogButtonBox::StandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel), Qt::Horizontal, this);
QObject::connect( _buttonBox, SIGNAL(rejected()), this, SLOT(reject()) );
QObject::connect( _buttonBox, SIGNAL(accepted()), this, SLOT(accept()) );
_mainLayout->addWidget(_buttonBox);
}

void
AddFavoriteDialog::setLabelText(const QString & text)
{
_descriptionLabel->setText(text);
}

void
AddFavoriteDialog::openDir()
{
QString str = QFileDialog::getExistingDirectory( this, tr("Select a directory"), _fd->currentDirectory().path(), QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog );

_pathLineEdit->setText(str);
}

QString
AddFavoriteDialog::textValue() const
{
return _pathLineEdit->text();
}

void
SequenceFileDialog::addFavorite()
{
AddFavoriteDialog dialog(this, this);

dialog.setLabelText( tr("Folder path:") );
QString newFavName, newFavPath;
if ( dialog.exec() ) {
newFavName = dialog.textValue();
newFavPath = dialog.textValue();
addFavorite(newFavName, newFavPath);
}
// add the current directory
QString newFav = currentDirectory().absolutePath();
addFavorite(newFav, newFav);
}

void
Expand Down Expand Up @@ -2404,7 +2357,9 @@ void
FavoriteView::setModelAndUrls(QFileSystemModel *model,
const std::vector<QUrl> &newUrls)
{
setIconSize( QSize(24, 24) );
setIconSize( QSize(appFontSize, appFontSize) ); // setIconSize resets the font of the QListView AND the QComboBox!!!
setFont( QFont(appFont, appFontSize) );

setUniformItemSizes(true);
assert(!urlModel);

Expand All @@ -2420,9 +2375,12 @@ FavoriteView::setModelAndUrls(QFileSystemModel *model,
setEditTriggers(QAbstractItemView::NoEditTriggers);

setDragDropMode(QAbstractItemView::DragDrop);
setContextMenuPolicy(Qt::CustomContextMenu);
connect( this, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showMenu(QPoint)) );

// we don't need a context menu here, there are the "+" and "-" buttons
//setContextMenuPolicy(Qt::CustomContextMenu);
//connect( this, SIGNAL(customContextMenuRequested(QPoint)),
// this, SLOT(showMenu(QPoint)) );

urlModel->setUrls(newUrls);
setCurrentIndex( this->model()->index(0, 0) );
connect( selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
Expand Down Expand Up @@ -2490,6 +2448,8 @@ FavoriteView::removeEntry()
}
}

// we don't need a favorite editor: just remove and add a new one
/*
void
FavoriteView::rename()
{
Expand All @@ -2507,9 +2467,11 @@ FavoriteView::rename()
}
}
QString newName;
#warning "TODO: use NATRON_PYTHON_NAMESPACE::PyModalDialog"
QInputDialog dialog(this);
dialog.setLabelText( tr("Favorite Name:") );
dialog.setWindowTitle( tr("Rename Favorite") );
dialog.setAttribute(Qt::WA_MacShowFocusRect, 0);
if ( dialog.exec() ) {
newName = dialog.textValue();
}
Expand All @@ -2522,7 +2484,10 @@ FavoriteView::rename(const QModelIndex & index,
{
model()->setData(index, name, Qt::EditRole);
}
*/

// we don't need an editor: just romove favorite and add a new one
/*
void
FavoriteView::editUrl()
{
Expand All @@ -2540,9 +2505,11 @@ FavoriteView::editUrl()
}
}
QString newName;
#warning "TODO: use NATRON_PYTHON_NAMESPACE::PyModalDialog"
QInputDialog dialog(this);
dialog.setLabelText( tr("Folder Path:") );
dialog.setWindowTitle( tr("Change Folder Path") );
dialog.setAttribute(Qt::WA_MacShowFocusRect, 0);
if ( dialog.exec() ) {
newName = dialog.textValue();
}
Expand All @@ -2561,6 +2528,7 @@ FavoriteView::editUrl()
}
myurlModel->setUrl(index, url, idx);
}
*/

void
FavoriteView::clicked(const QModelIndex &index)
Expand All @@ -2571,6 +2539,8 @@ FavoriteView::clicked(const QModelIndex &index)
selectUrl(url);
}

// we don't need a context menu, there are the "+" and "-" buttons
/*
void
FavoriteView::showMenu(const QPoint &position)
{
Expand All @@ -2597,6 +2567,7 @@ FavoriteView::showMenu(const QPoint &position)
menu.exec( mapToGlobal(position) );
}
}
*/

void
FavoriteView::keyPressEvent(QKeyEvent* e)
Expand Down Expand Up @@ -2698,6 +2669,8 @@ FileDialogComboBox::FileDialogComboBox(SequenceFileDialog *p,
, dialog(p)
, doResize(false)
{
setIconSize( QSize(appFontSize, appFontSize) ); // setIconSize resets the font of the QListView AND the QComboBox!!!
setFont( QFont(appFont, appFontSize) );
urlModel->setFileSystemModel( p->getLookingFileSystemModel() );
setModel(urlModel);
QObject::connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)) );
Expand Down
Loading

0 comments on commit 6d43554

Please sign in to comment.