diff --git a/bin/app/data/gui/window/listbox.css b/bin/app/data/gui/window/listbox.css index e9d84e63..e6e207f1 100644 --- a/bin/app/data/gui/window/listbox.css +++ b/bin/app/data/gui/window/listbox.css @@ -34,7 +34,7 @@ QtListItemWidget #field { border-top: 1px solid lightgray; } -#plusButton, #minusButton, #dotsButton { +#plusButton, #minusButton, #dotsButton, #editButton { color: white; height: 1em; margin-right: 3px; @@ -70,6 +70,15 @@ QtListItemWidget #field { border-image: url(window/dots_hover.png); } +#editButton { + border-image: url(code_view/images/edit.png); + margin-left: 6px; +} + +#editButton:hover { + background-color: #EEE; +} + #dropInfo { color: #999; } diff --git a/bin/app/data/gui/window/window.css b/bin/app/data/gui/window/window.css index 58fa237b..8880d449 100644 --- a/bin/app/data/gui/window/window.css +++ b/bin/app/data/gui/window/window.css @@ -160,7 +160,7 @@ background: #CFD2E0; } -#files { +#textField { border: 1px solid lightgray; border-radius: 12px; padding: 6px; diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index 56a7a7c9..a1be57a2 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -131,8 +131,6 @@ add_files( qt/window/project_wizzard/QtProjectWizzardContentSelect.h qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp qt/window/project_wizzard/QtProjectWizzardContentSimple.h - qt/window/project_wizzard/QtProjectWizzardContentSourceList.cpp - qt/window/project_wizzard/QtProjectWizzardContentSourceList.h qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp qt/window/project_wizzard/QtProjectWizzardContentSummary.h qt/window/project_wizzard/QtProjectWizzardWindow.cpp @@ -150,6 +148,8 @@ add_files( qt/window/QtSplashScreen.h qt/window/QtStartScreen.cpp qt/window/QtStartScreen.h + qt/window/QtTextEditDialog.cpp + qt/window/QtTextEditDialog.h qt/window/QtWindow.cpp qt/window/QtWindow.h qt/window/QtWindowStack.cpp diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.cpp b/src/lib_gui/qt/element/QtDirectoryListBox.cpp index 58b063aa..30328c78 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.cpp +++ b/src/lib_gui/qt/element/QtDirectoryListBox.cpp @@ -9,8 +9,10 @@ #include #include "utility/ResourcePaths.h" +#include "utility/utilityString.h" #include "qt/utility/utilityQt.h" +#include "qt/window/QtTextEditDialog.h" QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* item, QWidget *parent) : QWidget(parent) @@ -102,8 +104,9 @@ void QtListItemWidget::handleFocus() } -QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, bool forStrings) +QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName, bool forStrings) : QFrame(parent) + , m_listName(listName) , m_forStrings(forStrings) { QBoxLayout* layout = new QVBoxLayout(); @@ -147,6 +150,12 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, bool forStrings) dropInfoText->setAlignment(Qt::AlignRight); innerLayout->addWidget(dropInfoText); + QPushButton* editButton = new QPushButton("", this); + editButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + editButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac + editButton->setObjectName("editButton"); + innerLayout->addWidget(editButton); + if (isForStrings()) { dropInfoText->hide(); @@ -160,6 +169,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, bool forStrings) connect(m_addButton, SIGNAL(clicked()), this, SLOT(addListBoxItem())); connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeListBoxItem())); + connect(editButton, SIGNAL(clicked()), this, SLOT(showEditDialog())); setAcceptDrops(true); setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Minimum); @@ -330,3 +340,46 @@ void QtDirectoryListBox::dragEnterEvent(QDragEnterEvent *event) { event->accept(); } + +void QtDirectoryListBox::showEditDialog() +{ + if (!m_editDialog) + { + m_editDialog = std::make_shared(m_listName, "Edit the list in plain text. Each line is one item."); + m_editDialog->setup(); + + m_editDialog->setText(utility::join(getStringList(), "\n")); + + connect(m_editDialog.get(), SIGNAL(canceled()), this, SLOT(canceledEditDialog())); + connect(m_editDialog.get(), SIGNAL(finished()), this, SLOT(savedEditDialog())); + } + + m_editDialog->showWindow(); + m_editDialog->raise(); +} + +void QtDirectoryListBox::canceledEditDialog() +{ + m_editDialog->hide(); + m_editDialog.reset(); + + window()->raise(); +} + +void QtDirectoryListBox::savedEditDialog() +{ + std::vector lines = utility::splitToVector(m_editDialog->getText(), "\n"); + for (size_t i = 0; i < lines.size(); i++) + { + lines[i] = utility::trim(lines[i]); + + if (!lines[i].size()) + { + lines.erase(lines.begin() + i); + i--; + } + } + setStringList(lines); + + canceledEditDialog(); +} diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.h b/src/lib_gui/qt/element/QtDirectoryListBox.h index 16b3a58c..b93e50a9 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.h +++ b/src/lib_gui/qt/element/QtDirectoryListBox.h @@ -12,6 +12,7 @@ #include "qt/element/QtLineEdit.h" class QtDirectoryListBox; +class QtTextEditDialog; class QtListItemWidget : public QWidget @@ -46,7 +47,7 @@ class QtDirectoryListBox Q_OBJECT public: - QtDirectoryListBox(QWidget *parent, bool forStrings = false); + QtDirectoryListBox(QWidget *parent, const QString& listName, bool forStrings = false); virtual QSize sizeHint() const override; @@ -74,12 +75,19 @@ private slots: QtListItemWidget* addListBoxItem(); void removeListBoxItem(); + void showEditDialog(); + void canceledEditDialog(); + void savedEditDialog(); + private: QPushButton* m_addButton; QPushButton* m_removeButton; QListWidget* m_list; + QString m_listName; bool m_forStrings; + + std::shared_ptr m_editDialog; }; #endif // QT_DIRECTORY_LIST_BOX_H diff --git a/src/lib_gui/qt/window/QtTextEditDialog.cpp b/src/lib_gui/qt/window/QtTextEditDialog.cpp new file mode 100644 index 00000000..238eb977 --- /dev/null +++ b/src/lib_gui/qt/window/QtTextEditDialog.cpp @@ -0,0 +1,60 @@ +#include "qt/window/QtTextEditDialog.h" + +#include +#include + +#include "utility/utilityString.h" + +QtTextEditDialog::QtTextEditDialog(const QString& title, const QString& description, QWidget* parent) + : QtWindow(parent) + , m_title(title) + , m_description(description) +{ +} + +QSize QtTextEditDialog::sizeHint() const +{ + return QSize(550, 550); +} + +void QtTextEditDialog::setText(const std::string& text) +{ + m_text->setPlainText(QString::fromStdString(text)); +} + +std::string QtTextEditDialog::getText() +{ + return m_text->toPlainText().toStdString(); +} + +void QtTextEditDialog::setReadOnly(bool readOnly) +{ + m_text->setReadOnly(readOnly); +} + +void QtTextEditDialog::populateWindow(QWidget* widget) +{ + QVBoxLayout* layout = new QVBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + + QLabel* description = new QLabel(m_description); + description->setObjectName("description"); + layout->addWidget(description); + + m_text = new QPlainTextEdit(); + m_text->setObjectName("textField"); + m_text->setLineWrapMode(QPlainTextEdit::NoWrap); + layout->addWidget(m_text); + + widget->setLayout(layout); +} + +void QtTextEditDialog::windowReady() +{ + updateNextButton("Ok"); + updateCloseButton("Cancel"); + + setPreviousVisible(false); + + updateTitle(m_title); +} diff --git a/src/lib_gui/qt/window/QtTextEditDialog.h b/src/lib_gui/qt/window/QtTextEditDialog.h new file mode 100644 index 00000000..67bb2fb3 --- /dev/null +++ b/src/lib_gui/qt/window/QtTextEditDialog.h @@ -0,0 +1,34 @@ +#ifndef QT_TEXT_EDIT_DIALOG_H +#define QT_TEXT_EDIT_DIALOG_H + +#include "qt/window/QtWindow.h" + +class QPlainTextEdit; + +class QtTextEditDialog + : public QtWindow +{ + Q_OBJECT + +public: + QtTextEditDialog(const QString& title, const QString& description, QWidget* parent = 0); + + QSize sizeHint() const override; + + void setText(const std::string& text); + std::string getText(); + + void setReadOnly(bool readOnly); + +protected: + void populateWindow(QWidget* widget) override; + void windowReady() override; + +private: + QString m_title; + QString m_description; + + QPlainTextEdit* m_text; +}; + +#endif // QT_TEXT_EDIT_DIALOG_H diff --git a/src/lib_gui/qt/window/QtWindow.cpp b/src/lib_gui/qt/window/QtWindow.cpp index 3f3fd324..0d50a97d 100644 --- a/src/lib_gui/qt/window/QtWindow.cpp +++ b/src/lib_gui/qt/window/QtWindow.cpp @@ -362,10 +362,13 @@ void QtWindow::setupDone() QSize size(qMax(actualSize.width(), preferredSize.width()), qMax(actualSize.height(), preferredSize.height())); resize(size); - move( - parentWidget()->pos().x() + parentWidget()->width() / 2 - size.width() / 2, - parentWidget()->pos().y() + parentWidget()->height() / 2 - size.height() / 2 - ); + if (parentWidget()) + { + move( + parentWidget()->pos().x() + parentWidget()->width() / 2 - size.width() / 2, + parentWidget()->pos().y() + parentWidget()->height() / 2 - size.height() / 2 + ); + } } void QtWindow::addLogo() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index dd46e276..d7f616bf 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -13,7 +13,6 @@ #include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h" #include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h" #include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h" -#include "qt/window/project_wizzard/QtProjectWizzardContentSourceList.h" #include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h" #include "qt/window/project_wizzard/QtProjectWizzardWindow.h" #include "settings/CxxProjectSettings.h" @@ -278,36 +277,6 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithSummary( return window; } -template -QtProjectWizzardWindow* QtProjectWizzard::createPopupWithContent() -{ - QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget()); - - window->setShowAsPopup(true); - window->setContent(new T(m_settings, window)); - window->setup(); - - window->move(window->pos() + QPoint(50, 50)); - window->show(); - - connect(window, SIGNAL(next()), this, SLOT(popupClosed())); - - if (m_popup) - { - m_popup->hide(); - } - - m_popup = std::shared_ptr(window); - - return window; -} - -void QtProjectWizzard::connectShowFiles(QtProjectWizzardContent* content) -{ - connect(content, SIGNAL(filesButtonClicked(QtProjectWizzardContent*)), - this, SLOT(showFiles(QtProjectWizzardContent*))); -} - void QtProjectWizzard::cancelWizzard() { m_windowStack.clearWindows(); @@ -330,16 +299,6 @@ void QtProjectWizzard::windowStackChanged() } } -void QtProjectWizzard::popupClosed() -{ - QWidget* window = m_windowStack.getTopWindow(); - - if (window) - { - window->raise(); - } -} - void QtProjectWizzard::selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type) { switch (type) @@ -410,11 +369,7 @@ void QtProjectWizzard::sourcePaths() QtProjectWizzardWindow* window = createWindowWithSummary( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary) { - - QtProjectWizzardContent* source = new QtProjectWizzardContentPathsSource(m_settings, window); - summary->addContent(source, false, false); - connectShowFiles(source); - + summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window), false, false); summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window), false, false); window->setup(); @@ -481,12 +436,8 @@ void QtProjectWizzard::headerPathsCDB() QtProjectWizzardWindow* window = createWindowWithSummary( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary) { - QtProjectWizzardContent* source = new QtProjectWizzardContentCDBSource(m_settings, window); - summary->addContent(source, false, false); - connectShowFiles(source); - - QtProjectWizzardContent* header = new QtProjectWizzardContentPathsCDBHeader(m_settings, window); - summary->addContent(header, false, false); + summary->addContent(new QtProjectWizzardContentCDBSource(m_settings, window), false, false); + summary->addContent(new QtProjectWizzardContentPathsCDBHeader(m_settings, window), false, false); window->setup(); @@ -518,11 +469,7 @@ void QtProjectWizzard::sourcePathsJava() QtProjectWizzardWindow* window = createWindowWithSummary( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary) { - - QtProjectWizzardContent* source = new QtProjectWizzardContentPathsSourceJava(m_settings, window); - summary->addContent(source, false, false); - connectShowFiles(source); - + summary->addContent(new QtProjectWizzardContentPathsSourceJava(m_settings, window), false, false); summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window), false, false); window->setup(); @@ -532,19 +479,6 @@ void QtProjectWizzard::sourcePathsJava() connect(window, SIGNAL(next()), this, SLOT(showSummaryJava())); } -void QtProjectWizzard::showFiles(QtProjectWizzardContent* content) -{ - QWidget* widget = m_windowStack.getTopWindow(); - if (widget) - { - QtProjectWizzardWindow* win = dynamic_cast(widget); - win->content()->save(); - } - - QtProjectWizzardWindow* window = createPopupWithContent(); - dynamic_cast(window->content())->showFilesFromContent(content); -} - void QtProjectWizzard::showSummary() { QtProjectWizzardWindow* window = createWindowWithSummary( @@ -567,10 +501,7 @@ void QtProjectWizzard::showSummary() this, SLOT(refreshProjectFromSolution(const std::string&, const std::string&))); } - QtProjectWizzardContentPathsSource* source = new QtProjectWizzardContentPathsSource(m_settings, window); - summary->addContent(source, false, true); - connectShowFiles(source); - + summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window), false, true); summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_settings, window), false, true); summary->addContent(new QtProjectWizzardContentSimple(m_settings, window), false, false); summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window), false, false); @@ -620,10 +551,7 @@ void QtProjectWizzard::showSummaryJava() summary->addContent(new QtProjectWizzardContentData(m_settings, window), false, false); - QtProjectWizzardContentPathsSourceJava* source = new QtProjectWizzardContentPathsSourceJava(m_settings, window); - summary->addContent(source, false, true); - connectShowFiles(source); - + summary->addContent(new QtProjectWizzardContentPathsSourceJava(m_settings, window), false, true); summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window), false, true); summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window), true, false); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h index 52d7b0c5..dec0ec74 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h @@ -46,13 +46,10 @@ private: QtProjectWizzardWindow* createWindowWithSummary( std::function func); - template - QtProjectWizzardWindow* createPopupWithContent(); void connectShowFiles(QtProjectWizzardContent* content); QtWindowStack m_windowStack; - std::shared_ptr m_popup; std::shared_ptr m_settings; ApplicationSettings m_appSettings; @@ -66,7 +63,6 @@ private slots: void finishWizzard(); void windowStackChanged(); - void popupClosed(); void selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type); @@ -84,8 +80,6 @@ private slots: void sourcePathsJava(); - void showFiles(QtProjectWizzardContent* content); - void showSummary(); void showSummaryJava(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp index f2ca7c51..bc6f3318 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp @@ -2,6 +2,9 @@ #include +#include "qt/window/QtTextEditDialog.h" +#include "utility/utilityString.h" + QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent) : QPushButton("", parent) , m_helpText(helpText) @@ -31,10 +34,6 @@ QtProjectWizzardContent::QtProjectWizzardContent(std::shared_ptr QtProjectWizzardContent::getFileNames() const { - return QStringList(); + return std::vector(); } QString QtProjectWizzardContent::getFileNamesTitle() const @@ -126,12 +125,37 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout* QPushButton* button = new QPushButton(name); button->setObjectName("windowButton"); layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop); - connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + connect(button, SIGNAL(clicked()), this, SLOT(filesButtonClicked())); return button; } -void QtProjectWizzardContent::buttonClicked() +void QtProjectWizzardContent::filesButtonClicked() { - emit filesButtonClicked(this); + if (!m_filesDialog) + { + std::vector fileNames = getFileNames(); + + m_filesDialog = std::make_shared( + getFileNamesTitle(), QString::number(fileNames.size()) + " " + getFileNamesDescription()); + m_filesDialog->setup(); + + m_filesDialog->setText(utility::join(fileNames, "\n")); + m_filesDialog->setCloseVisible(false); + m_filesDialog->setReadOnly(true); + + connect(m_filesDialog.get(), SIGNAL(finished()), this, SLOT(closedFilesDialog())); + connect(m_filesDialog.get(), SIGNAL(canceled()), this, SLOT(closedFilesDialog())); + } + + m_filesDialog->showWindow(); + m_filesDialog->raise(); +} + +void QtProjectWizzardContent::closedFilesDialog() +{ + m_filesDialog->hide(); + m_filesDialog.reset(); + + window()->raise(); } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h index 6471702c..e341a727 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h @@ -10,6 +10,7 @@ #include "qt/window/project_wizzard/QtProjectWizzardWindow.h" #include "settings/ProjectSettings.h" +class QtTextEditDialog; class QtHelpButton : public QPushButton @@ -35,7 +36,6 @@ class QtProjectWizzardContent public: QtProjectWizzardContent(std::shared_ptr settings, QtProjectWizzardWindow* window); - virtual void populateWindow(QWidget* widget); virtual void populateWindow(QGridLayout* layout, int& row); virtual void populateForm(QGridLayout* layout, int& row); virtual void windowReady(); @@ -48,13 +48,10 @@ public: virtual QSize preferredWindowSize() const; - virtual QStringList getFileNames() const; + virtual std::vector getFileNames() const; virtual QString getFileNamesTitle() const; virtual QString getFileNamesDescription() const; -signals: - void filesButtonClicked(QtProjectWizzardContent* content); - protected: QLabel* createFormLabel(QString name) const; QLabel* createFormTitle(QString name) const; @@ -67,7 +64,11 @@ protected: QtProjectWizzardWindow* m_window; private slots: - void buttonClicked(); + void filesButtonClicked(); + void closedFilesDialog(); + +private: + std::shared_ptr m_filesDialog; }; #endif // QT_PROJECT_WIZZARD_CONTENT_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp index b8855622..0e783df5 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp @@ -65,7 +65,7 @@ void QtProjectWizzardContentCDBSource::load() path = path.relativeTo(projectPath); } - m_fileNames << QString::fromStdString(path.str()); + m_fileNames.push_back(path.str()); } } if (m_text) @@ -74,7 +74,7 @@ void QtProjectWizzardContentCDBSource::load() } } -QStringList QtProjectWizzardContentCDBSource::getFileNames() const +std::vector QtProjectWizzardContentCDBSource::getFileNames() const { return m_fileNames; } @@ -86,5 +86,5 @@ QString QtProjectWizzardContentCDBSource::getFileNamesTitle() const QString QtProjectWizzardContentCDBSource::getFileNamesDescription() const { - return "source files will be indexed."; + return " source files will be indexed."; } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h index 0d56c427..18ff8e19 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h @@ -16,13 +16,13 @@ public: virtual void load() override; - virtual QStringList getFileNames() const override; + virtual std::vector getFileNames() const override; virtual QString getFileNamesTitle() const override; virtual QString getFileNamesDescription() const override; private: QLabel* m_text; - QStringList m_fileNames; + std::vector m_fileNames; }; #endif // QT_PROJECT_WIZZARD_CONTENT_CDB_SOURCE_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp index 8bf49547..16ad8a51 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp @@ -27,7 +27,7 @@ void QtProjectWizzardContentExtensions::populateWindow(QGridLayout* layout, int& layout->addWidget(text, row + 1, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); layout->setRowStretch(row + 1, 1); - m_sourceList = new QtDirectoryListBox(this); + m_sourceList = new QtDirectoryListBox(this, title->text()); layout->addWidget(m_sourceList, row, QtProjectWizzardWindow::BACK_COL, 2, 1, Qt::AlignTop); row += 2; } @@ -40,7 +40,7 @@ void QtProjectWizzardContentExtensions::populateForm(QGridLayout* layout, int& r addHelpButton("Define extensions for source files including the dot e.g. .cpp", layout, row); - m_sourceList = new QtDirectoryListBox(this, true); + m_sourceList = new QtDirectoryListBox(this, sourceLabel->text(), true); layout->addWidget(m_sourceList, row, QtProjectWizzardWindow::BACK_COL); row++; } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp index d7da2e80..c51831d5 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp @@ -18,7 +18,7 @@ void QtProjectWizzardContentFlags::populateForm(QGridLayout* layout, int& row) addHelpButton("Define compiler flags used during indexing including the dash e.g. -v", layout, row); - m_list = new QtDirectoryListBox(this, true); + m_list = new QtDirectoryListBox(this, label->text(), true); layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL); row++; } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 1c3880b8..32988ea6 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -34,7 +34,7 @@ void QtProjectWizzardContentPaths::populateWindow(QGridLayout* layout, int& row) layout->addWidget(text, row + 1, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop); layout->setRowStretch(row + 1, 1); - m_list = new QtDirectoryListBox(this); + m_list = new QtDirectoryListBox(this, m_titleString); layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL, 2, 1, Qt::AlignTop); row += 2; @@ -66,7 +66,7 @@ void QtProjectWizzardContentPaths::populateForm(QGridLayout* layout, int& row) addHelpButton(m_helpString, layout, row); } - m_list = new QtDirectoryListBox(this); + m_list = new QtDirectoryListBox(this, m_titleString); layout->addWidget(m_list, row, QtProjectWizzardWindow::BACK_COL); row++; @@ -223,7 +223,7 @@ void QtProjectWizzardContentPathsSource::save() m_settings->setSourcePaths(m_list->getList()); } -QStringList QtProjectWizzardContentPathsSource::getFileNames() const +std::vector QtProjectWizzardContentPathsSource::getFileNames() const { std::vector sourcePaths = m_settings->getAbsoluteSourcePaths(); std::vector excludePaths = m_settings->getAbsoluteExcludePaths(); @@ -232,7 +232,7 @@ QStringList QtProjectWizzardContentPathsSource::getFileNames() const std::vector fileInfos = FileSystem::getFileInfosFromPaths(sourcePaths, extensions); FilePath projectPath = m_settings->getProjectFileLocation(); - QStringList list; + std::vector list; for (const FileInfo& info : fileInfos) { FilePath path = info.path; @@ -257,7 +257,7 @@ QStringList QtProjectWizzardContentPathsSource::getFileNames() const path = path.relativeTo(projectPath); } - list << QString::fromStdString(path.str()); + list.push_back(path.str()); } return list; @@ -270,7 +270,7 @@ QString QtProjectWizzardContentPathsSource::getFileNamesTitle() const QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const { - return "files will be indexed."; + return " files will be indexed."; } QtProjectWizzardContentPathsSourceJava::QtProjectWizzardContentPathsSourceJava( diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h index 39de148c..6a28cc72 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h @@ -64,7 +64,7 @@ public: virtual void load() override; virtual void save() override; - virtual QStringList getFileNames() const override; + virtual std::vector getFileNames() const override; virtual QString getFileNamesTitle() const override; virtual QString getFileNamesDescription() const override; }; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceList.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceList.cpp deleted file mode 100644 index 62ece988..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceList.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "qt/window/project_wizzard/QtProjectWizzardContentSourceList.h" - -#include -#include - -QtProjectWizzardContentSourceList::QtProjectWizzardContentSourceList( - std::shared_ptr settings, QtProjectWizzardWindow* window -) - : QtProjectWizzardContent(settings, window) -{ -} - -void QtProjectWizzardContentSourceList::populateWindow(QWidget* widget) -{ - QVBoxLayout* layout = new QVBoxLayout(widget); - layout->setContentsMargins(0, 0, 0, 0); - - m_text = new QLabel("0 files will be indexed."); - m_text->setWordWrap(true); - layout->addWidget(m_text); - - m_list = new QListView(this); - m_list->setObjectName("files"); - m_list->setEditTriggers(QAbstractItemView::NoEditTriggers); - m_list->setSelectionMode(QAbstractItemView::NoSelection); - m_list->setAttribute(Qt::WA_MacShowFocusRect, 0); - layout->addWidget(m_list); -} - -void QtProjectWizzardContentSourceList::windowReady() -{ -} - -QSize QtProjectWizzardContentSourceList::preferredWindowSize() const -{ - return QSize(500, 500); -} - -void QtProjectWizzardContentSourceList::showFilesFromContent(QtProjectWizzardContent* content) -{ - QStringList list = content->getFileNames(); - m_text->setText(QString::number(list.size()) + " " + content->getFileNamesDescription()); - m_window->updateTitle(content->getFileNamesTitle()); - - QStringListModel* model = new QStringListModel(this); - model->setStringList(list); - m_list->setModel(model); -} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceList.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceList.h deleted file mode 100644 index 3d0f9f68..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSourceList.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_SOURCE_LIST_H -#define QT_PROJECT_WIZZARD_CONTENT_SOURCE_LIST_H - -#include "qt/window/project_wizzard/QtProjectWizzardContent.h" - -class QLabel; -class QListView; - -class QtProjectWizzardContentSourceList - : public QtProjectWizzardContent -{ -public: - QtProjectWizzardContentSourceList(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtSettingsWindow implementation - virtual void populateWindow(QWidget* widget) override; - virtual void windowReady() override; - - virtual QSize preferredWindowSize() const override; - - void showFilesFromContent(QtProjectWizzardContent* content); - -private: - QLabel* m_text; - QListView* m_list; -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_SOURCE_LIST_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp index 882f710c..3beb71f2 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp @@ -43,31 +43,24 @@ void QtProjectWizzardWindow::populateWindow(QWidget* widget) int row = 0; m_content->populateWindow(layout, row); - if (layout->columnCount() < 2) + QFrame* separator = new QFrame(); + separator->setFrameShape(QFrame::VLine); + + QPalette palette = separator->palette(); + palette.setColor(QPalette::WindowText, Qt::lightGray); + separator->setPalette(palette); + + layout->addWidget(separator, 0, LINE_COL, -1, 1); + + layout->setColumnStretch(HELP_COL, 0); + layout->setColumnStretch(LINE_COL, 0); + + if (isScrollAble()) { - m_content->populateWindow(widget); + layout->setColumnMinimumWidth(BACK_COL + 1, 10); } - else - { - QFrame* separator = new QFrame(); - separator->setFrameShape(QFrame::VLine); - QPalette palette = separator->palette(); - palette.setColor(QPalette::WindowText, Qt::lightGray); - separator->setPalette(palette); - - layout->addWidget(separator, 0, LINE_COL, -1, 1); - - layout->setColumnStretch(HELP_COL, 0); - layout->setColumnStretch(LINE_COL, 0); - - if (isScrollAble()) - { - layout->setColumnMinimumWidth(BACK_COL + 1, 10); - } - - widget->setLayout(layout); - } + widget->setLayout(layout); } void QtProjectWizzardWindow::windowReady()