Dockable page list widget.

This commit is contained in:
Leonardo Zide 2021-01-06 14:06:15 -08:00
parent 2d5d719902
commit 5c2a5aa167
2 changed files with 37 additions and 20 deletions

View file

@ -36,25 +36,31 @@ void lcInstructionsPageWidget::SetCurrentPage(const lcInstructionsPage* Page)
}
}
lcInstructionsPageListWidget::lcInstructionsPageListWidget(QWidget* Parent)
: QDockWidget(Parent)
{
QWidget* CentralWidget = new QWidget(this);
setWidget(CentralWidget);
setWindowTitle(tr("Pages"));
QHBoxLayout* Layout = new QHBoxLayout(CentralWidget);
Layout->setContentsMargins(0, 0, 0, 0);
mThumbnailsWidget = new QListWidget(CentralWidget);
Layout->addWidget(mThumbnailsWidget);
}
lcInstructionsDialog::lcInstructionsDialog(QWidget* Parent, Project* Project)
: QMainWindow(Parent), mProject(Project)
{
QWidget* CentralWidget = new QWidget(this);
setCentralWidget(CentralWidget);
setWindowTitle(tr("Instructions"));
QVBoxLayout* Layout = new QVBoxLayout(CentralWidget);
Layout->setContentsMargins(0, 0, 0, 0);
mPageWidget = new lcInstructionsPageWidget(this);
setCentralWidget(mPageWidget);
QSplitter* Splitter = new QSplitter(CentralWidget);
Splitter->setOrientation(Qt::Horizontal);
Layout->addWidget(Splitter);
mThumbnailsWidget = new QListWidget(Splitter);
Splitter->addWidget(mThumbnailsWidget);
mPageWidget = new lcInstructionsPageWidget(Splitter);
Splitter->addWidget(mPageWidget);
mPageListWidget = new lcInstructionsPageListWidget(this);
mPageListWidget->setObjectName("PageList");
addDockWidget(Qt::LeftDockWidgetArea, mPageListWidget);
mInstructions = mProject->GetInstructions();
@ -79,10 +85,10 @@ lcInstructionsDialog::lcInstructionsDialog(QWidget* Parent, Project* Project)
PageDirectionGroup->addAction(mHorizontalPageAction);
for (size_t PageNumber = 0; PageNumber < mInstructions.mPages.size(); PageNumber++)
mThumbnailsWidget->addItem(QString("Page %1").arg(PageNumber + 1));
mPageListWidget->mThumbnailsWidget->addItem(QString("Page %1").arg(PageNumber + 1));
connect(mThumbnailsWidget, SIGNAL(currentRowChanged(int)), this, SLOT(CurrentThumbnailChanged(int)));
mThumbnailsWidget->setCurrentRow(0);
connect(mPageListWidget->mThumbnailsWidget, SIGNAL(currentRowChanged(int)), this, SLOT(CurrentThumbnailChanged(int)));
mPageListWidget->mThumbnailsWidget->setCurrentRow(0);
connect(mVerticalPageAction, SIGNAL(toggled()), this, SLOT(UpdatePageSettings()));
connect(mHorizontalPageAction, SIGNAL(toggled()), this, SLOT(UpdatePageSettings()));
@ -105,9 +111,9 @@ void lcInstructionsDialog::UpdatePageSettings()
mInstructions.SetDefaultPageSettings(PageSettings);
// lcInstructionsPage* Page = &mInstructions.mPages[mThumbnailsWidget->currentIndex().row()];
mThumbnailsWidget->clear();
mPageListWidget->mThumbnailsWidget->clear();
for (size_t PageNumber = 0; PageNumber < mInstructions.mPages.size(); PageNumber++)
mThumbnailsWidget->addItem(QString("Page %1").arg(PageNumber + 1));
mPageListWidget->mThumbnailsWidget->addItem(QString("Page %1").arg(PageNumber + 1));
// mThumbnailsWidget->setCurrentRow(0);

View file

@ -12,6 +12,17 @@ public:
void SetCurrentPage(const lcInstructionsPage* Page);
};
class lcInstructionsPageListWidget : public QDockWidget
{
Q_OBJECT
public:
lcInstructionsPageListWidget(QWidget* Parent);
//protected:
QListWidget* mThumbnailsWidget = nullptr;
};
class lcInstructionsDialog : public QMainWindow
{
Q_OBJECT
@ -29,8 +40,8 @@ protected:
int mCurrentPageNumber;
lcInstructions mInstructions;
QListWidget* mThumbnailsWidget = nullptr;
lcInstructionsPageWidget* mPageWidget = nullptr ;
lcInstructionsPageWidget* mPageWidget = nullptr;
lcInstructionsPageListWidget* mPageListWidget = nullptr;
QToolBar* mPageSettingsToolBar = nullptr;
QAction* mVerticalPageAction = nullptr;