Skip to content

Commit

Permalink
Improve switching between panels
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkanovikov committed Dec 10, 2022
1 parent 18e090f commit 88863a5
Show file tree
Hide file tree
Showing 51 changed files with 130 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,7 @@ bool ProjectManager::event(QEvent* _event)
// При смене сфокусированного виджета, проверяем не изменился ли активный из редакторов
//

if (!d->view.right->isVisible() || !d->view.active->isAnimationFinished()) {
if (!d->view.right->isVisible()) {
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ AudioplayInformationView::AudioplayInformationView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins({});
layout->setSpacing(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ AudioplayParametersView::AudioplayParametersView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins({});
layout->setSpacing(0);
Expand Down
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/audioplay_statistics
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,11 @@ void AudioplayTextView::setCursors(const QVector<Domain::CursorInfo>& _cursors)
d->textEdit->setCursors(_cursors);
}

void AudioplayTextView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

void AudioplayTextView::reconfigure(const QStringList& _changedSettingsKeys)
{
UiHelper::initSpellingFor(d->textEdit);
Expand Down Expand Up @@ -920,11 +925,6 @@ QModelIndex AudioplayTextView::currentModelIndex() const
return d->textEdit->currentModelIndex();
}

void AudioplayTextView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

int AudioplayTextView::cursorPosition() const
{
return d->textEdit->textCursor().position();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AudioplayTextView : public Widget, public IDocumentView
QVector<QAction*> options() const override;
void setEditingMode(ManagementLayer::DocumentEditingMode _mode) override;
void setCursors(const QVector<Domain::CursorInfo>& _cursors) override;
void setCurrentModelIndex(const QModelIndex& _index) override;
/** @} */

/**
Expand All @@ -53,11 +54,6 @@ class AudioplayTextView : public Widget, public IDocumentView
*/
QModelIndex currentModelIndex() const;

/**
* @brief Поставить курсор в позицию элемента с заданным индексом модели
*/
void setCurrentModelIndex(const QModelIndex& _index);

/**
* @brief Позиция курсора
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ QModelIndex AudioplayTextEdit::currentModelIndex() const

void AudioplayTextEdit::setCurrentModelIndex(const QModelIndex& _index)
{
if (!_index.isValid() || _index.model() != d->model) {
return;
}

BusinessLayer::TextCursor textCursor(document());
textCursor.setPosition(d->document.itemStartPosition(_index));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void AudioplayTextStructureManager::setCurrentModelIndex(const QModelIndex& _ind
if (!indexForSelect.isValid()) {
indexForSelect = d->structureModel->mapFromSource(_index.parent().parent());
}
d->view->setCurrentModelIndex(_index.parent(), indexForSelect);
d->view->setCurrentModelIndex(indexForSelect);
d->modelIndexToSelect = {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ void AudioplayTextStructureView::setEditingMode(ManagementLayer::DocumentEditing
d->content->setDragDropEnabled(!readOnly);
}

void AudioplayTextStructureView::setCurrentModelIndex(const QModelIndex& _index)
{
d->content->setCurrentIndex(_index);
}

void AudioplayTextStructureView::reconfigure()
{
const bool showSceneNumber
Expand Down Expand Up @@ -126,13 +131,6 @@ void AudioplayTextStructureView::setModel(QAbstractItemModel* _model)
d->content->setModel(_model);
}

void AudioplayTextStructureView::setCurrentModelIndex(const QModelIndex& _sourceIndex,
const QModelIndex& _mappedIndex)
{
Q_UNUSED(_sourceIndex)
d->content->setCurrentIndex(_mappedIndex);
}

QModelIndexList AudioplayTextStructureView::selectedIndexes() const
{
return d->content->selectedIndexes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AudioplayTextStructureView : public AbstractNavigator, public IDocumentVie
/** @{ */
QWidget* asQWidget() override;
void setEditingMode(ManagementLayer::DocumentEditingMode _mode) override;
void setCurrentModelIndex(const QModelIndex& _index) override;
/** @} */

/**
Expand All @@ -43,11 +44,6 @@ class AudioplayTextStructureView : public AbstractNavigator, public IDocumentVie
*/
void setModel(QAbstractItemModel* _model);

/**
* @brief Установить текущий выделенный элемент в модели
*/
void setCurrentModelIndex(const QModelIndex& _sourceIndex, const QModelIndex& _mappedIndex);

/**
* @brief Список выделенных элементов
*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/character_information
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/characters_relations
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ ComicBookInformationView::ComicBookInformationView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins({});
layout->setSpacing(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ ComicBookParametersView::ComicBookParametersView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins({});
layout->setSpacing(0);
Expand Down
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/comic_book_statistics
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,11 @@ void ComicBookTextView::setCursors(const QVector<Domain::CursorInfo>& _cursors)
d->textEdit->setCursors(_cursors);
}

void ComicBookTextView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

void ComicBookTextView::reconfigure(const QStringList& _changedSettingsKeys)
{
UiHelper::initSpellingFor(d->textEdit);
Expand Down Expand Up @@ -919,11 +924,6 @@ QModelIndex ComicBookTextView::currentModelIndex() const
return d->textEdit->currentModelIndex();
}

void ComicBookTextView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

int ComicBookTextView::cursorPosition() const
{
return d->textEdit->textCursor().position();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ComicBookTextView : public Widget, public IDocumentView
QVector<QAction*> options() const override;
void setEditingMode(ManagementLayer::DocumentEditingMode _mode) override;
void setCursors(const QVector<Domain::CursorInfo>& _cursors) override;
void setCurrentModelIndex(const QModelIndex& _index) override;
/** @} */

/**
Expand All @@ -53,11 +54,6 @@ class ComicBookTextView : public Widget, public IDocumentView
*/
QModelIndex currentModelIndex() const;

/**
* @brief Поставить курсор в позицию элемента с заданным индексом модели сценария
*/
void setCurrentModelIndex(const QModelIndex& _index);

/**
* @brief Позиция курсора
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ QModelIndex ComicBookTextEdit::currentModelIndex() const

void ComicBookTextEdit::setCurrentModelIndex(const QModelIndex& _index)
{
if (!_index.isValid() || _index.model() != d->model) {
return;
}

BusinessLayer::TextCursor textCursor(document());
textCursor.setPosition(d->document.itemStartPosition(_index));
ensureCursorVisible(textCursor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ void ComicBookTextStructureView::setEditingMode(ManagementLayer::DocumentEditing
d->content->setDragDropEnabled(!readOnly);
}

void ComicBookTextStructureView::setCurrentModelIndex(const QModelIndex& _index)
{
d->content->setCurrentIndex(_index);
}

void ComicBookTextStructureView::reconfigure()
{
const bool showSceneText
Expand Down Expand Up @@ -120,11 +125,6 @@ void ComicBookTextStructureView::setModel(QAbstractItemModel* _model)
d->content->setModel(_model);
}

void ComicBookTextStructureView::setCurrentModelIndex(const QModelIndex& _index)
{
d->content->setCurrentIndex(_index);
}

QModelIndexList ComicBookTextStructureView::selectedIndexes() const
{
return d->content->selectedIndexes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ComicBookTextStructureView : public AbstractNavigator, public IDocumentVie
/** @{ */
QWidget* asQWidget() override;
void setEditingMode(ManagementLayer::DocumentEditingMode _mode) override;
void setCurrentModelIndex(const QModelIndex& _index) override;
/** @} */

/**
Expand All @@ -40,11 +41,6 @@ class ComicBookTextStructureView : public AbstractNavigator, public IDocumentVie
*/
void setModel(QAbstractItemModel* _model);

/**
* @brief Установить текущий выделенный элемент в модели
*/
void setCurrentModelIndex(const QModelIndex& _index);

/**
* @brief Список выделенных элементов
*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/images_gallery
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/location_information
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/locations_map
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/project_collaborators
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ ProjectInformationView::ProjectInformationView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins({});
layout->setSpacing(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ RecycleBinView::RecycleBinView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

auto layout = new QVBoxLayout;
layout->setContentsMargins(QMargins());
layout->setSpacing(0);
Expand Down
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/screenplay_cards
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ ScreenplayInformationView::ScreenplayInformationView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins({});
layout->setSpacing(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ ScreenplayParametersView::ScreenplayParametersView(QWidget* _parent)
: Widget(_parent)
, d(new Implementation(this))
{
setFocusPolicy(Qt::StrongFocus);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins({});
layout->setSpacing(0);
Expand Down
2 changes: 1 addition & 1 deletion src/core/management_layer/plugins/screenplay_statistics
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,11 @@ void ScreenplayTextView::setCursors(const QVector<Domain::CursorInfo>& _cursors)
d->textEdit->setCursors(_cursors);
}

void ScreenplayTextView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

DictionariesView* ScreenplayTextView::dictionariesView() const
{
return d->dictionariesView;
Expand Down Expand Up @@ -1435,11 +1440,6 @@ QModelIndex ScreenplayTextView::currentModelIndex() const
return d->textEdit->currentModelIndex();
}

void ScreenplayTextView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

int ScreenplayTextView::cursorPosition() const
{
return d->textEdit->textCursor().position();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ScreenplayTextView : public Widget, public IDocumentView
QVector<QAction*> options() const override;
void setEditingMode(ManagementLayer::DocumentEditingMode _mode) override;
void setCursors(const QVector<Domain::CursorInfo>& _cursors) override;
void setCurrentModelIndex(const QModelIndex& _index) override;
/** @} */

/**
Expand Down Expand Up @@ -59,11 +60,6 @@ class ScreenplayTextView : public Widget, public IDocumentView
*/
QModelIndex currentModelIndex() const;

/**
* @brief Поставить курсор в позицию элемента с заданным индексом модели сценария
*/
void setCurrentModelIndex(const QModelIndex& _index);

/**
* @brief Позиция курсора
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ QModelIndex ScreenplayTextEdit::currentModelIndex() const

void ScreenplayTextEdit::setCurrentModelIndex(const QModelIndex& _index)
{
if (!_index.isValid() || _index.model() != d->model) {
return;
}

BusinessLayer::TextCursor textCursor(document());
textCursor.setPosition(d->document.itemStartPosition(_index));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,11 @@ void ScreenplayTreatmentView::setCursors(const QVector<Domain::CursorInfo>& _cur
d->textEdit->setCursors(_cursors);
}

void ScreenplayTreatmentView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

void ScreenplayTreatmentView::reconfigure(const QStringList& _changedSettingsKeys)
{
UiHelper::initSpellingFor(d->textEdit);
Expand Down Expand Up @@ -934,11 +939,6 @@ QModelIndex ScreenplayTreatmentView::currentModelIndex() const
return d->textEdit->currentModelIndex();
}

void ScreenplayTreatmentView::setCurrentModelIndex(const QModelIndex& _index)
{
d->textEdit->setCurrentModelIndex(_index);
}

int ScreenplayTreatmentView::cursorPosition() const
{
return d->textEdit->textCursor().position();
Expand Down
Loading

0 comments on commit 88863a5

Please sign in to comment.