diff --git a/bin/app/data/gui/settingwindows/listbox.css b/bin/app/data/gui/settingwindows/listbox.css index 89782c7a..8b452bbf 100644 --- a/bin/app/data/gui/settingwindows/listbox.css +++ b/bin/app/data/gui/settingwindows/listbox.css @@ -1,27 +1,64 @@ -.QtDirectoryListBox { - border: 1px solid lightgray; - border-radius: 15px; - background-color: rgba(255, 255, 255, 200); +QtDirectoryListBox { + background-color: rgba(255, 255, 255, 200); + border: 1px solid lightgray; + border-radius: 12px; } -.QListWidget { - border: none; - background: transparent; +QListWidget { + background: transparent; + border: none; + margin: 2px 0 2px 0; +} + +QListWidget::item { + border-bottom: 1px solid lightgray; + height: 20px; +} + +QListWidget::item:selected { + background-color: #EEE; +} + + +QtListItemWidget #field { + background-color: transparent; + border: none; + font-size: 12px; + margin-top: 2px; +} + +QtListItemWidget #button { + border: 1px solid lightgray; + border-radius: 8px; + font-size: 12px; + margin-top: 2px; + margin-right: 2px; + width: 20px; +} + +QtListItemWidget #button:hover { + color: white; + background: #2D3F85; +} + +#bar { + border-top: 1px solid lightgray; } #roundedButton { - font-size: 15px; - color: white; - border-radius: 10px; - background: dimgray; - width: 20px; - height: 20px; + background: dimgray; + border-radius: 8px; + color: white; + font-size: 15px; + height: 16px; + margin-right: 3px; + width: 16px; } #roundedButton:hover { - background: lightgray; + background: gray; } #dropInfo { - color: lightgray; + color: lightgray; } diff --git a/bin/app/data/gui/settingwindows/projectsetup.css b/bin/app/data/gui/settingwindows/projectsetup.css index 38a9ffe8..09b1e20b 100644 --- a/bin/app/data/gui/settingwindows/projectsetup.css +++ b/bin/app/data/gui/settingwindows/projectsetup.css @@ -1,39 +1,63 @@ +#titleLabel { + color: black; + font-size: 16pt; + font-weight: bold; +} + QLineEdit { - border-radius: 10px; - border: 1px solid lightgrey; - background-color: rgba(255, 255, 255, 200); + background-color: rgba(255, 255, 255, 200); + border-radius: 10px; + border: 1px solid lightgrey; + padding-left: 5px; + padding-right: 5px; +} + +QLineEdit:disabled { + border: 1px solid lightgrey; +} + +#formArea { + background-color: transparent; + border: none; + border-top: 1px solid lightgrey; + border-bottom: 1px solid lightgrey; } #form { - background-color: rgba(255, 255, 255, 200); - border: none; + background-color: rgba(255, 255, 255, 220); +} + +#form QLabel { + font-weight: bold; } #moreButton { - font-size: 15px; - margin-left: 10px; - color: gray; - border-radius: 10px; - border: 1px solid lightgray; - background: white; - width: 40px; - height: 20px; + background-color: rgba(255, 255, 255, 200); + border: 1px solid lightgray; + border-radius: 10px; + color: gray; + font-size: 15px; + height: 20px; + margin-left: 10px; + width: 28px; } -#moreutton:hover { - background: lightgray; +#moreButton:hover { + color: white; + background: #2D3F85; } #windowButton { - margin-left: 10px; - color: black; - border-radius: 10px; - border: 1px solid lightgray; - background: white; - width: 40px; - height: 20px; + background: white; + border: 1px solid lightgray; + border-radius: 10px; + color: black; + font-size: 17pt; + height: 30px; + width: 140px; } #windowButton:hover { - background: lightgray; + color: white; + background: #2D3F85; } diff --git a/bin/app/data/gui/startscreen/logo_schriftzug.png b/bin/app/data/gui/startscreen/logo_schriftzug.png index 02807313..ac955102 100755 Binary files a/bin/app/data/gui/startscreen/logo_schriftzug.png and b/bin/app/data/gui/startscreen/logo_schriftzug.png differ diff --git a/bin/app/data/gui/startscreen/startscreen.css b/bin/app/data/gui/startscreen/startscreen.css index c59555ff..3be3e854 100644 --- a/bin/app/data/gui/startscreen/startscreen.css +++ b/bin/app/data/gui/startscreen/startscreen.css @@ -1,28 +1,35 @@ #projectButton { + background: white; + border: 1px solid lightgray; + border-radius: 10px; font-size: 17pt; - border: 1px solid lightgray; - border-radius: 10px; - background: white; } #projectButton:hover { - color: white; - background: navy; + background: #2D3F85; + color: white; } -#recentButton{ - font-size: 12pt; - color: black; - background: none; - border: none; +#recentButton { + background: none; + border: none; + color: black; + font-size: 12pt; } -#recentButton:hover{ - background: lightgray; - border-radius: 10px; +#recentButton:hover { + background-color: rgba(45, 63, 133, 70); + border-radius: 10px; } #recentLabel { - font-size: 16pt; color: black; + font-size: 16pt; + font-weight: bold; +} + +QToolTip { + background-color: ; + color: ; + font-size: pt; } diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 028d0574..6032b91e 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -17,6 +17,8 @@ add_files( qt/element/QtCodeSnippet.h qt/element/QtDirectoryListBox.cpp qt/element/QtDirectoryListBox.h + qt/element/QtLineEdit.cpp + qt/element/QtLineEdit.h qt/element/QtMainWindow.cpp qt/element/QtMainWindow.h qt/element/QtProjectSetupScreen.cpp diff --git a/src/app/qt/element/QtDirectoryListBox.cpp b/src/app/qt/element/QtDirectoryListBox.cpp index c763aa86..7ea17d0e 100644 --- a/src/app/qt/element/QtDirectoryListBox.cpp +++ b/src/app/qt/element/QtDirectoryListBox.cpp @@ -3,46 +3,113 @@ #include #include #include -#include #include #include "qt/utility/utilityQt.h" +QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* item, QWidget *parent) + : QWidget(parent) + , m_list(list) + , m_item(item) +{ + QBoxLayout* layout = new QHBoxLayout(); + layout->setSpacing(3); + layout->setContentsMargins(0, 0, 0, 0); + layout->setAlignment(Qt::AlignTop); + + m_data = new QtLineEdit(this); + m_data->setAttribute(Qt::WA_MacShowFocusRect, 0); + m_data->setObjectName("field"); + + m_button = new QPushButton("..."); + m_button->setObjectName("button"); + + layout->addWidget(m_data); + layout->addWidget(m_button); + + setLayout(layout); + + connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress())); + connect(m_data, SIGNAL(focus()), this, SLOT(handleFocus())); +} + +QString QtListItemWidget::getText() +{ + return m_data->text(); +} + +void QtListItemWidget::setText(QString text) +{ + m_data->setText(text); +} + +void QtListItemWidget::setFocus() +{ + m_data->setFocus(Qt::OtherFocusReason); +} + +void QtListItemWidget::handleButtonPress() +{ + QFileDialog dialog(this); + if (dialog.exec()) + { + QStringList list = dialog.selectedFiles(); + for (int i = 0; i < list.size(); i++) + { + setText(list.at(i)); + } + } + + handleFocus(); +} + +void QtListItemWidget::handleFocus() +{ + m_list->selectItem(m_item); +} + + QtDirectoryListBox::QtDirectoryListBox(QWidget *parent) - :QFrame(parent) + :QFrame(parent) { - setObjectName("QtListBox"); - setMinimumHeight(150); QBoxLayout* layout = new QVBoxLayout(); layout->setSpacing(0); - layout->setContentsMargins(10, 10, 10, 10); + layout->setContentsMargins(0, 6, 0, 0); layout->setAlignment(Qt::AlignTop); + m_list = new QListWidget(this); + m_list->setObjectName("list"); + m_list->setAttribute(Qt::WA_MacShowFocusRect, 0); setStyleSheet(utility::getStyleSheet("data/gui/settingwindows/listbox.css").c_str()); layout->addWidget(m_list); QWidget* buttonContainer = new QWidget(this); - QBoxLayout* innerLayout = new QHBoxLayout(); - innerLayout->setContentsMargins(0,0,0,0); + buttonContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + buttonContainer->setObjectName("bar"); - m_addButton = new QPushButton("+",this); - m_addButton->resize(20,20); - m_addButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + QHBoxLayout* innerLayout = new QHBoxLayout(); + innerLayout->setContentsMargins(8, 4, 8, 3); + innerLayout->setSpacing(0); + + m_addButton = new QPushButton("+", this); + m_addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_addButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_addButton->setObjectName("roundedButton"); innerLayout->addWidget(m_addButton); - m_removeButton = new QPushButton("-",this); - m_removeButton->resize(20,20); - m_removeButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + m_removeButton = new QPushButton("-", this); + m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_removeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_removeButton->setObjectName("roundedButton"); innerLayout->addWidget(m_removeButton); - QLabel* dropInfoText = new QLabel("You can drop Folders here"); - dropInfoText->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + QLabel* dropInfoText = new QLabel("Drop Files & Folders"); + dropInfoText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); dropInfoText->setObjectName("dropInfo"); dropInfoText->setAlignment(Qt::AlignRight); innerLayout->addWidget(dropInfoText); + buttonContainer->setLayout(innerLayout); layout->addWidget(buttonContainer); setLayout(layout); @@ -51,6 +118,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent) connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeListBoxItem())); setAcceptDrops(true); + resize(); } void QtDirectoryListBox::dropEvent(QDropEvent *event) @@ -58,62 +126,79 @@ void QtDirectoryListBox::dropEvent(QDropEvent *event) QFileInfo fileInfo; foreach(QUrl url, event->mimeData()->urls()) { - fileInfo.setFile(url.toLocalFile()); - if(fileInfo.isDir()) - { - QListWidgetItem *item = new QListWidgetItem(m_list); - m_list->addItem(item); - item->setText(url.toLocalFile()); - } + QtListItemWidget* widget = addListBoxItem(); + widget->setText(url.toLocalFile()); } } std::vector QtDirectoryListBox::getList() { std::vector list; - for( int i = 0; i < m_list->count(); ++i) + for (int i = 0; i < m_list->count(); ++i) { - QListWidgetItem* item = m_list->item(i); - list.push_back(item->text().toStdString()); + QtListItemWidget* widget = dynamic_cast(m_list->itemWidget(m_list->item(i))); + list.push_back(widget->getText().toStdString()); } - return list; } -void QtDirectoryListBox::addListBoxItem() +void QtDirectoryListBox::setList(const std::vector& list) { - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::DirectoryOnly); - dialog.setOption(QFileDialog::ShowDirsOnly, true); - dialog.setOption(QFileDialog::DontUseNativeDialog,true); + m_list->clear(); - // enable multiselection of directories - QListView *l = dialog.findChild("listView"); - if (l) - { - l->setSelectionMode(QAbstractItemView::MultiSelection); - } - QTreeView *t = dialog.findChild(); - if (t) - { - t->setSelectionMode(QAbstractItemView::MultiSelection); - } - - if(dialog.exec()) + for (const FilePath& path : list) { - QStringList list = dialog.selectedFiles(); - for(int i = 0; i < list.size(); i++) - { - QListWidgetItem *item = new QListWidgetItem(m_list); - m_list->addItem(item); - item->setText(list.at(i)); - } + QtListItemWidget* widget = addListBoxItem(); + widget->setText(QString::fromStdString(path.str())); } } +void QtDirectoryListBox::selectItem(QListWidgetItem* item) +{ + for (int i = 0; i < m_list->count(); i++) + { + m_list->item(i)->setSelected(false); + } + + item->setSelected(true); +} + +void QtDirectoryListBox::resize() +{ + int height = 25; + + if (m_list->count() > 0) + { + height += (m_list->itemWidget(m_list->item(0))->height() + 1) * m_list->count() + 8; + } + + if (height < 150) + { + height = 150; + } + + setMinimumHeight(height); +} + +QtListItemWidget* QtDirectoryListBox::addListBoxItem() +{ + QListWidgetItem *item = new QListWidgetItem(m_list); + m_list->addItem(item); + + QtListItemWidget* widget = new QtListItemWidget(this, item); + m_list->setItemWidget(item, widget); + + resize(); + + widget->setFocus(); + + return widget; +} + void QtDirectoryListBox::removeListBoxItem() { qDeleteAll(m_list->selectedItems()); + resize(); } void QtDirectoryListBox::dragEnterEvent(QDragEnterEvent *event) diff --git a/src/app/qt/element/QtDirectoryListBox.h b/src/app/qt/element/QtDirectoryListBox.h index 33f1c732..ca85e431 100644 --- a/src/app/qt/element/QtDirectoryListBox.h +++ b/src/app/qt/element/QtDirectoryListBox.h @@ -1,30 +1,72 @@ -#ifndef QT_DIRECTORYLISTBOX_H -#define QT_DIRECTORYLISTBOX_H +#ifndef QT_DIRECTORY_LIST_BOX_H +#define QT_DIRECTORY_LIST_BOX_H #include +#include #include #include #include #include "utility/file/FilePath.h" -class QtDirectoryListBox : public QFrame +#include "qt/element/QtLineEdit.h" + +class QtDirectoryListBox; + +class QtListItemWidget + : public QWidget { -Q_OBJECT + Q_OBJECT + +public: + QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* item, QWidget *parent = nullptr); + + QString getText(); + void setText(QString text); + +public slots: + void setFocus(); + +private slots: + void handleButtonPress(); + void handleFocus(); + +private: + QPushButton* m_button; + QtLineEdit* m_data; + + QtDirectoryListBox* m_list; + QListWidgetItem* m_item; +}; + + +class QtDirectoryListBox + : public QFrame +{ + Q_OBJECT + public: QtDirectoryListBox(QWidget *parent); + std::vector getList(); + void setList(const std::vector& list); + + void selectItem(QListWidgetItem* item); + protected: void dropEvent(QDropEvent *event); void dragEnterEvent(QDragEnterEvent* event); + private: + void resize(); + QPushButton* m_addButton; QPushButton* m_removeButton; QListWidget* m_list; private slots: - void addListBoxItem(); + QtListItemWidget* addListBoxItem(); void removeListBoxItem(); }; -#endif //QT_DIRECTORYLISTBOX_H +#endif // QT_DIRECTORY_LIST_BOX_H diff --git a/src/app/qt/element/QtLineEdit.cpp b/src/app/qt/element/QtLineEdit.cpp new file mode 100644 index 00000000..9fe002f1 --- /dev/null +++ b/src/app/qt/element/QtLineEdit.cpp @@ -0,0 +1,12 @@ +#include "qt/element/QtLineEdit.h" + +QtLineEdit::QtLineEdit(QWidget* parent) + : QLineEdit(parent) +{ +} + +void QtLineEdit::focusInEvent(QFocusEvent* event) +{ + emit focus(); + QLineEdit::focusInEvent(event); +} diff --git a/src/app/qt/element/QtLineEdit.h b/src/app/qt/element/QtLineEdit.h new file mode 100644 index 00000000..3d604d9a --- /dev/null +++ b/src/app/qt/element/QtLineEdit.h @@ -0,0 +1,21 @@ +#ifndef QT_LINE_EDIT_H +#define QT_LINE_EDIT_H + +#include + +class QtLineEdit + : public QLineEdit +{ + Q_OBJECT + +public: + QtLineEdit(QWidget* parent = nullptr); + +signals: + void focus(); + +protected: + void focusInEvent(QFocusEvent* event); +}; + +#endif // QT_LINE_EDIT_H diff --git a/src/app/qt/element/QtMainWindow.cpp b/src/app/qt/element/QtMainWindow.cpp index 18ea08bc..ba7faed6 100644 --- a/src/app/qt/element/QtMainWindow.cpp +++ b/src/app/qt/element/QtMainWindow.cpp @@ -16,7 +16,6 @@ #include "utility/messaging/type/MessageFind.h" #include "utility/messaging/type/MessageInterruptTasks.h" #include "utility/messaging/type/MessageLoadProject.h" -#include "utility/messaging/type/MessageLoadSource.h" #include "utility/messaging/type/MessageRedo.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageSaveProject.h" @@ -26,6 +25,7 @@ #include "utility/messaging/type/MessageZoom.h" QtMainWindow::QtMainWindow() + : m_startScreenWasVisible(false) { setObjectName("QtMainWindow"); setCentralWidget(nullptr); @@ -50,10 +50,7 @@ QtMainWindow::QtMainWindow() void QtMainWindow::init() { - // StartScreen - m_startScreen = std::make_shared(this); - m_startScreen->setup(); - m_startScreen->show(); + showStartScreen(); } @@ -157,10 +154,66 @@ void QtMainWindow::about() ); } +void QtMainWindow::hideScreens() +{ + if (m_startScreen) + { + m_startScreen->hide(); + } + + if (m_newProjectDialog) + { + m_newProjectDialog->hide(); + } +} + +void QtMainWindow::restoreScreens() +{ + hideScreens(); + + if (m_startScreen && m_startScreenWasVisible) + { + m_startScreen->show(); + } + + m_startScreenWasVisible = false; +} + +void QtMainWindow::showStartScreen() +{ + if (!m_startScreen) + { + m_startScreen = std::make_shared(this); + m_startScreen->setup(); + connect(m_startScreen.get(), SIGNAL(finished()), this, SLOT(hideScreens())); + } + + m_startScreen->show(); + m_startScreenWasVisible = true; + + if (m_newProjectDialog) + { + m_newProjectDialog->hide(); + } +} + void QtMainWindow::newProject() { - m_newProjectDialog = std::make_shared(this); - m_newProjectDialog->setup(); + if (m_startScreen) + { + m_startScreen->hide(); + } + + if (!m_newProjectDialog) + { + m_newProjectDialog = std::make_shared(this); + m_newProjectDialog->setup(); + + connect(m_newProjectDialog.get(), SIGNAL(finished()), this, SLOT(hideScreens())); + connect(m_newProjectDialog.get(), SIGNAL(canceled()), this, SLOT(restoreScreens())); + } + + m_newProjectDialog->loadEmpty(); m_newProjectDialog->show(); } @@ -179,6 +232,12 @@ void QtMainWindow::openProject(const QString &path) } } +void QtMainWindow::editProject() +{ + newProject(); + m_newProjectDialog->loadProjectSettings(); +} + void QtMainWindow::find() { MessageFind().dispatch(); @@ -248,14 +307,6 @@ void QtMainWindow::switchColorScheme() void QtMainWindow::handleEscapeShortcut() { - if(m_startScreen) - { - m_startScreen->hide(); - } - if(m_newProjectDialog) - { - m_newProjectDialog->hide(); - } MessageInterruptTasks().dispatch(); } @@ -264,10 +315,13 @@ void QtMainWindow::setupProjectMenu() QMenu *menu = new QMenu(tr("&Project"), this); menuBar()->addMenu(menu); - menu->addAction(tr("Ope&n Source Folder..."), this, SLOT(newProject()), QKeySequence::New); - menu->addAction(tr("&Open Coati Project..."), this, SLOT(openProject()), QKeySequence::Open); - menu->addAction(tr("&Save"), this, SLOT(saveProject()), QKeySequence::Save); - menu->addAction(tr("Save as..."), this, SLOT(saveAsProject()), QKeySequence::SaveAs); + menu->addAction(tr("&New Project..."), this, SLOT(newProject()), QKeySequence::New); + menu->addAction(tr("&Open Project..."), this, SLOT(openProject()), QKeySequence::Open); + menu->addAction(tr("&Edit Project..."), this, SLOT(editProject())); + + menu->addAction(tr("&Save Project"), this, SLOT(saveProject()), QKeySequence::Save); + menu->addAction(tr("Save Project as..."), this, SLOT(saveAsProject()), QKeySequence::SaveAs); + menu->addAction(tr("&Close Window"), this, SLOT(closeWindow()), QKeySequence::Close); menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit); } diff --git a/src/app/qt/element/QtMainWindow.h b/src/app/qt/element/QtMainWindow.h index 907fe9b8..deace827 100644 --- a/src/app/qt/element/QtMainWindow.h +++ b/src/app/qt/element/QtMainWindow.h @@ -38,14 +38,23 @@ protected: public slots: void about(); + void hideScreens(); + void restoreScreens(); + void showStartScreen(); + void newProject(); void openProject(const QString &path = QString()); + void editProject(); + void find(); void closeWindow(); void refresh(); + void saveProject(); void saveAsProject(); + void showLicences(); + void undo(); void redo(); void zoomIn(); @@ -70,6 +79,8 @@ private: std::vector> m_dockWidgets; QShortcut* m_escapeShortcut; + + bool m_startScreenWasVisible; }; #endif // QT_MAIN_WINDOW_H diff --git a/src/app/qt/element/QtProjectSetupScreen.cpp b/src/app/qt/element/QtProjectSetupScreen.cpp index 293d2567..724f4680 100644 --- a/src/app/qt/element/QtProjectSetupScreen.cpp +++ b/src/app/qt/element/QtProjectSetupScreen.cpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include - #include "settings/ProjectSettings.h" #include "utility/logging/logging.h" #include "qt/utility/QtDeviceScaledPixmap.h" @@ -16,7 +16,7 @@ #include "qt/utility/utilityQt.h" QtTextLine::QtTextLine(QWidget *parent) - :QWidget(parent) + : QWidget(parent) { QBoxLayout* layout = new QHBoxLayout(); layout->setSpacing(0); @@ -25,14 +25,19 @@ QtTextLine::QtTextLine(QWidget *parent) setLayout(layout); - m_data = new QLineEdit(this); + m_data = new QtLineEdit(this); + m_data->setAttribute(Qt::WA_MacShowFocusRect, 0); + m_data->setObjectName("locationField"); + m_data->setReadOnly(true); + m_button = new QPushButton("..."); - m_button->setMaximumWidth(40); m_button->setObjectName("moreButton"); + layout->addWidget(m_data); layout->addWidget(m_button); connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress())); + connect(m_data, SIGNAL(focus()), this, SLOT(handleButtonPress())); } QString QtTextLine::getText() @@ -47,7 +52,7 @@ void QtTextLine::setText(QString text) void QtTextLine::handleButtonPress() { - QString file = QFileDialog::getExistingDirectory(this, tr("Select File"), ""); + QString file = QFileDialog::getExistingDirectory(this, tr("Select Directory"), ""); if (!file.isEmpty()) { m_data->setText(file); @@ -62,121 +67,180 @@ QtProjectSetupScreen::QtProjectSetupScreen(QWidget *parent) void QtProjectSetupScreen::setup() { + QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo.png"); + coati_logo.scaleToWidth(400); + QLabel* coatiLogoLabel = new QLabel(m_window); + coatiLogoLabel->setPixmap(coati_logo.pixmap()); + coatiLogoLabel->resize(coati_logo.width(), coati_logo.height()); + coatiLogoLabel->move(100, 100); + setStyleSheet(utility::getStyleSheet("data/gui/settingwindows/projectsetup.css").c_str()); QVBoxLayout* windowLayout = new QVBoxLayout(); - windowLayout->setContentsMargins(20,30,20,20); - QLabel* windowTitleLabel = new QLabel("NEW PROJECT"); - windowLayout->addWidget(windowTitleLabel); + windowLayout->setContentsMargins(25, 30, 25, 20); + + m_title = new QLabel(); + m_title->setObjectName("titleLabel"); + windowLayout->addWidget(m_title); windowLayout->addSpacing(30); QScrollArea* scrollArea = new QScrollArea(); - scrollArea->setObjectName("coatiBackground"); + scrollArea->setObjectName("formArea"); + scrollArea->setFrameShadow(QFrame::Plain); + scrollArea->setWidgetResizable(true); + QWidget* form = new QWidget(); form->setObjectName("form"); scrollArea->setWidget(form); - scrollArea->setFrameShadow(QFrame::Plain); - scrollArea->setWidgetResizable(true); - QFormLayout *layout = new QFormLayout(); - layout->setContentsMargins(20,30,20,20); - //Background Image - QPalette p = palette(); - QPixmap pixmap1("data/gui/startscreen/logo.png"); - QRect rect = scrollArea->rect(); - QSize size(rect.width()-90,rect.height()); - QPixmap pixmap(pixmap1.scaled(size)); - p.setBrush(QPalette::Background, pixmap); - scrollArea->setPalette(p); + QFormLayout *layout = new QFormLayout(); + layout->setContentsMargins(10, 10, 10, 10); + layout->setHorizontalSpacing(20); + + int minimumWidthForSecondCol = 360; QLabel* nameLabel = new QLabel("Name"); m_projectName = new QLineEdit(); + m_projectName->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + m_projectName->setMinimumWidth(minimumWidthForSecondCol); + m_projectName->setAttribute(Qt::WA_MacShowFocusRect, 0); layout->addRow(nameLabel, m_projectName); QLabel* locationLabel = new QLabel("Location"); m_projectFileLocation = new QtTextLine(this); + m_projectFileLocation->setMinimumWidth(minimumWidthForSecondCol); layout->addRow(locationLabel, m_projectFileLocation); - /* QLabel* languageLabel = new QLabel("Language"); QComboBox* language = new QComboBox(); language->insertItem(0, "C++"); layout->addRow(languageLabel, language); - */ - QLabel* sourcePathsLabel = new QLabel("Sourcepaths"); + QLabel* sourcePathsLabel = new QLabel("Source Paths"); m_sourcePaths = new QtDirectoryListBox(this); + m_sourcePaths->setMinimumWidth(minimumWidthForSecondCol); layout->addRow(sourcePathsLabel, m_sourcePaths); - QLabel* includePathsLabel = new QLabel("IncludePaths"); + QLabel* includePathsLabel = new QLabel("Include Paths"); m_includePaths = new QtDirectoryListBox(this); + m_includePaths->setMinimumWidth(minimumWidthForSecondCol); layout->addRow(includePathsLabel, m_includePaths); - if(QSysInfo::macVersion() != QSysInfo::MV_None) + if (QSysInfo::macVersion() != QSysInfo::MV_None) { - QLabel* frameworkPathsLabel = new QLabel("FrameworkPaths"); + QLabel* frameworkPathsLabel = new QLabel("Framework Paths"); m_frameworkPaths = new QtDirectoryListBox(this); + m_frameworkPaths->setMinimumWidth(minimumWidthForSecondCol); layout->addRow(frameworkPathsLabel, m_frameworkPaths); } + form->setLayout(layout); - QPushButton* createButton = new QPushButton("Create"); - createButton->setObjectName("windowButton"); - QPushButton* cancelButton = new QPushButton("Cancel"); - cancelButton->setObjectName("windowButton"); + m_createButton = new QPushButton("Create"); + m_createButton->setObjectName("windowButton"); + m_cancelButton = new QPushButton("Cancel"); + m_cancelButton->setObjectName("windowButton"); + m_updateButton = new QPushButton("Update"); + m_updateButton->setObjectName("windowButton"); - connect(createButton, SIGNAL(clicked()), this, SLOT(handleCreateButtonPress())); - connect(cancelButton, SIGNAL(clicked()), this, SLOT(handleCancelButtonPress())); + connect(m_createButton, SIGNAL(clicked()), this, SLOT(handleCreateButtonPress())); + connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(handleCancelButtonPress())); + connect(m_updateButton, SIGNAL(clicked()), this, SLOT(handleUpdateButtonPress())); QHBoxLayout* buttons = new QHBoxLayout(); - buttons->addSpacing(100); - buttons->addWidget(createButton); - buttons->addWidget(cancelButton); - buttons->addSpacing(30); + buttons->addWidget(m_cancelButton); + buttons->addStretch(); + buttons->addWidget(m_createButton); + buttons->addWidget(m_updateButton); windowLayout->addWidget(scrollArea); windowLayout->addSpacing(20); windowLayout->addLayout(buttons); m_window->setLayout(windowLayout); - resize(QSize(600,600)); + resize(QSize(600, 620)); + + scrollArea->raise(); } -void QtProjectSetupScreen::handleCancelButtonPress() +void QtProjectSetupScreen::loadEmpty() { - hide(); + m_updateButton->hide(); + m_createButton->show(); + + m_title->setText("NEW PROJECT"); +} + +void QtProjectSetupScreen::loadProjectSettings() +{ + m_updateButton->show(); + m_createButton->hide(); + + m_title->setText("EDIT PROJECT"); + + ProjectSettings* projSettings = ProjectSettings::getInstance().get(); + + m_projectName->setText(QString::fromStdString(projSettings->getFilePath().withoutExtension().fileName())); + m_projectFileLocation->setText(QString::fromStdString(projSettings->getFilePath().parentDirectory().str())); + + m_sourcePaths->setList(projSettings->getSourcePaths()); + m_includePaths->setList(projSettings->getHeaderSearchPaths()); + m_frameworkPaths->setList(projSettings->getFrameworkSearchPaths()); } void QtProjectSetupScreen::handleCreateButtonPress() { - bool error = false; - if(m_projectName->text().isEmpty()) + if (m_projectName->text().isEmpty()) { QMessageBox msgBox; - msgBox.setText("Please Enter a Project Name"); + msgBox.setText("Please enter a project name."); msgBox.exec(); - error = true; - } - if(m_projectFileLocation->getText().isEmpty()) - { - QMessageBox msgBox; - msgBox.setText("Location for the ProjectFiles is empty"); - msgBox.exec(); - error = true; + return; } - if(!error) + if (m_projectFileLocation->getText().isEmpty()) { - ProjectSettings::getInstance()->setSourcePaths(m_sourcePaths->getList()); - ProjectSettings::getInstance()->setHeaderSearchPaths(m_includePaths->getList()); - if(m_frameworkPaths) - { - ProjectSettings::getInstance()->setFrameworkSearchPaths(m_frameworkPaths->getList()); - } - std::string projectFile = - m_projectFileLocation->getText().toStdString() + "/" + m_projectName->text().toStdString() + ".xml"; - ProjectSettings::getInstance()->save(projectFile); - MessageLoadProject(projectFile).dispatch(); + QMessageBox msgBox; + msgBox.setText("Please define the location of the project file."); + msgBox.exec(); + return; } + + if (!m_sourcePaths->getList().size()) + { + QMessageBox msgBox; + msgBox.setText("Please add at least one source path to your project."); + msgBox.exec(); + return; + } + + ProjectSettings* projSettings = ProjectSettings::getInstance().get(); + + projSettings->clear(); + + projSettings->setSourcePaths(m_sourcePaths->getList()); + projSettings->setHeaderSearchPaths(m_includePaths->getList()); + + if (m_frameworkPaths) + { + projSettings->setFrameworkSearchPaths(m_frameworkPaths->getList()); + } + + std::string projectFile = + m_projectFileLocation->getText().toStdString() + "/" + m_projectName->text().toStdString() + ".xml"; + projSettings->save(projectFile); + + MessageLoadProject(projectFile).dispatch(); + emit finished(); +} + +void QtProjectSetupScreen::handleCancelButtonPress() +{ + emit canceled(); +} + +void QtProjectSetupScreen::handleUpdateButtonPress() +{ + handleCreateButtonPress(); } QSize QtProjectSetupScreen::sizeHint() const diff --git a/src/app/qt/element/QtProjectSetupScreen.h b/src/app/qt/element/QtProjectSetupScreen.h index bd3b2472..a13006ee 100644 --- a/src/app/qt/element/QtProjectSetupScreen.h +++ b/src/app/qt/element/QtProjectSetupScreen.h @@ -1,51 +1,72 @@ -#ifndef QTPROJECTSETUPSCREEN_H -#define QTPROJECTSETUPSCREEN_H +#ifndef QT_PROJECT_SETUP_SCREEN_H +#define QT_PROJECT_SETUP_SCREEN_H -#include #include #include #include #include "QtSettingsWindow.h" -#include "qt/element/QtDirectoryListBox.h" #include "utility/file/FilePath.h" -class QtTextLine : public QWidget +#include "qt/element/QtDirectoryListBox.h" +#include "qt/element/QtLineEdit.h" + +class QtTextLine + : public QWidget { -Q_OBJECT + Q_OBJECT + public: QtTextLine(QWidget *parent); QString getText(); void setText(QString text); -private: - QPushButton* m_button; - QLineEdit* m_data; + private slots: void handleButtonPress(); + +private: + QPushButton* m_button; + QtLineEdit* m_data; }; -class QtProjectSetupScreen : public QtSettingsWindow + +class QtProjectSetupScreen + : public QtSettingsWindow { -Q_OBJECT + Q_OBJECT + public: QtProjectSetupScreen(QWidget* parent = 0); QSize sizeHint() const Q_DECL_OVERRIDE; + virtual void setup() override; + + void loadEmpty(); + void loadProjectSettings(); + +signals: + void finished(); + void canceled(); + private slots: void handleCreateButtonPress(); void handleCancelButtonPress(); + void handleUpdateButtonPress(); private: QLineEdit* m_projectName; - QtDirectoryListBox *m_includePaths; - QtDirectoryListBox *m_sourcePaths; - QtDirectoryListBox *m_frameworkPaths; QtTextLine* m_projectFileLocation; - std::vector compilerFlags; - std::vector sourceExtensions; - std::vector headerExtensions; + + QLabel* m_title; + + QPushButton* m_createButton; + QPushButton* m_cancelButton; + QPushButton* m_updateButton; + + QtDirectoryListBox* m_includePaths; + QtDirectoryListBox* m_sourcePaths; + QtDirectoryListBox* m_frameworkPaths; }; - -#endif //QTPROJECTSETUPSCREEN_H +#endif //QT_PROJECT_SETUP_SCREEN_H diff --git a/src/app/qt/element/QtSettingsWindow.cpp b/src/app/qt/element/QtSettingsWindow.cpp index b6a3b48e..4dbc8111 100644 --- a/src/app/qt/element/QtSettingsWindow.cpp +++ b/src/app/qt/element/QtSettingsWindow.cpp @@ -1,48 +1,54 @@ #include "qt/element/QtSettingsWindow.h" #include +#include #include "utility/messaging/type/MessageInterruptTasks.h" QtSettingsWindow::QtSettingsWindow(QWidget *parent, int displacement) - : QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint ) + : QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint) , m_mousePressedInWindow(false) { QSize windowSize = sizeHint(); - move(parent->pos().x()+parent->width()/2-250,parent->pos().y()+parent->height()/2-250); + move(parent->pos().x() + parent->width() / 2 - 250, parent->pos().y() + parent->height() / 2 - 250); + setAttribute(Qt::WA_TranslucentBackground, true); m_displacment = displacement; + m_window = new QWidget(this); - windowSize.setHeight(windowSize.height()-displacement-10); - windowSize.setWidth(windowSize.width()-10); - m_window->move(0,displacement); - //m_window->setFixedSize(windowSize); + windowSize.setHeight(windowSize.height() - displacement - 10); + windowSize.setWidth(windowSize.width() - 10); + m_window->move(0, displacement); m_window->resize(windowSize); + std::string frameStyle = - "#SettingWindow {" - "font-size: 17pt; " - "border: 1px solid lightgray;" - "border-radius: 15px; " - "background: white; " - "background-image: url(:/data/gui/icon/logo_1024_1024.png); " - "}"; + "#SettingWindow {" + "font-size: 17pt; " + "border: 1px solid lightgray;" + "border-radius: 15px; " + "background: white; " + "background-image: url(:/data/gui/icon/logo_1024_1024.png); " + "}"; m_window->setStyleSheet(frameStyle.c_str()); m_window->setObjectName("SettingWindow"); - // test with window shadow - QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; - effect->setBlurRadius(5); - effect->setXOffset(2); - effect->setYOffset(2); - effect->setColor(Qt::darkGray); - m_window->setGraphicsEffect(effect); + // window shadow + if (QSysInfo::macVersion() == QSysInfo::MV_None) + { + QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; + effect->setBlurRadius(5); + effect->setXOffset(2); + effect->setYOffset(2); + effect->setColor(Qt::darkGray); + m_window->setGraphicsEffect(effect); + } this->raise(); } void QtSettingsWindow::keyPressEvent(QKeyEvent *event) { - if(event->key() == Qt::Key_Escape) + if (event->key() == Qt::Key_Escape) { this->hide(); } @@ -53,10 +59,11 @@ QSize QtSettingsWindow::sizeHint() const return QSize(500, 500); } -void QtSettingsWindow::resizeEvent(QResizeEvent *event) { - QSize windowSize = event->size()-QSize(10,10+m_displacment); +void QtSettingsWindow::resizeEvent(QResizeEvent *event) +{ + QSize windowSize = event->size()-QSize(10, 10 + m_displacment); m_window->resize(windowSize); - m_window->move(0,m_displacment); + m_window->move(0, m_displacment); } void QtSettingsWindow::mouseMoveEvent(QMouseEvent *event) diff --git a/src/app/qt/element/QtSettingsWindow.h b/src/app/qt/element/QtSettingsWindow.h index 642858ee..91e38ee8 100644 --- a/src/app/qt/element/QtSettingsWindow.h +++ b/src/app/qt/element/QtSettingsWindow.h @@ -1,31 +1,34 @@ -#ifndef QTSETTINGSWINDOW_H -#define QTSETTINGSWINDOW_H +#ifndef QT_SETTINGS_WINDOW_H +#define QT_SETTINGS_WINDOW_H -#include #include +#include -class QtSettingsWindow : public QWidget +class QtSettingsWindow + : public QWidget { Q_OBJECT public: QtSettingsWindow(QWidget* parent = 0, int displacement = 0); + QSize sizeHint() const Q_DECL_OVERRIDE; - virtual void setup() = 0; + + virtual void setup() = 0; protected: - QWidget* m_window; - void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + + QWidget* m_window; + private: int m_displacment; QPoint m_dragPosition; bool m_mousePressedInWindow; - //void mouse }; -#endif //QTSETTINGSWINDOW_H +#endif //QT_SETTINGS_WINDOW_H diff --git a/src/app/qt/element/QtStartScreen.cpp b/src/app/qt/element/QtStartScreen.cpp index faf32e9b..826ac6c4 100644 --- a/src/app/qt/element/QtStartScreen.cpp +++ b/src/app/qt/element/QtStartScreen.cpp @@ -22,11 +22,10 @@ QtRecentProjectButton::QtRecentProjectButton(const QString &text, QWidget *paren void QtRecentProjectButton::handleButtonClick() { MessageLoadProject(m_projectFile).dispatch(); - parentWidget()->hide(); }; QtStartScreen::QtStartScreen(QWidget *parent) - : QtSettingsWindow(parent, 50) + : QtSettingsWindow(parent, 68) { this->raise(); } @@ -37,7 +36,7 @@ void QtStartScreen::setup() std::vector recentProjects = ApplicationSettings::getInstance()->getRecentProjects(); QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo_schriftzug.png"); - coati_logo.scaleToWidth(250); + coati_logo.scaleToWidth(200); QLabel* coatiLogoLabel = new QLabel(this); coatiLogoLabel->setPixmap(coati_logo.pixmap()); coatiLogoLabel->resize(coati_logo.width(), coati_logo.height()); @@ -45,28 +44,28 @@ void QtStartScreen::setup() m_newProjectButton = new QPushButton("New Project", this); m_newProjectButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - m_newProjectButton->setGeometry(30, 375, 140, 30); + m_newProjectButton->setGeometry(30, 495, 140, 30); m_newProjectButton->setObjectName("projectButton"); connect(m_newProjectButton, SIGNAL(clicked()), this, SLOT(handleNewProjectButton())); m_openProjectButton = new QPushButton("Open Project", this); m_openProjectButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - m_openProjectButton->setGeometry(30, 420, 140, 30); + m_openProjectButton->setGeometry(30, 540, 140, 30); m_openProjectButton->setObjectName("projectButton"); connect(m_openProjectButton, SIGNAL(clicked()), this, SLOT(handleOpenProjectButton())); connect(this, SIGNAL(openOpenProjectDialog()), parent(), SLOT(openProject())); connect(this, SIGNAL(openNewProjectDialog()), parent(), SLOT(newProject())); - QLabel* recentProjectsLabel = new QLabel("RECENT PROJECTS: ", this); - recentProjectsLabel->setGeometry(300, 129, 300, 50); + QLabel* recentProjectsLabel = new QLabel("Recent Projects: ", this); + recentProjectsLabel->setGeometry(300, 234, 300, 50); recentProjectsLabel->setObjectName("recentLabel"); - int position = 200; + int position = 290; QIcon cpp_icon("data/gui/startscreen/Icon_CPP.png"); for (std::string project : recentProjects) { - if(FileSystem::exists(project.c_str())) + if (FileSystem::exists(project.c_str())) { QtRecentProjectButton* button = new QtRecentProjectButton(project.c_str(), this); button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac @@ -76,11 +75,12 @@ void QtStartScreen::setup() button->minimumSizeHint(); // force font loading button->setGeometry(292, position, button->fontMetrics().width(button->text()) + 45, 40); connect(button, SIGNAL(clicked()), button, SLOT(handleButtonClick())); + connect(button, SIGNAL(clicked()), this, SLOT(handleRecentButton())); position += 40; } } - resize(600,500); + resize(600, 600); } QSize QtStartScreen::sizeHint() const @@ -90,12 +90,15 @@ QSize QtStartScreen::sizeHint() const void QtStartScreen::handleNewProjectButton() { - this->hide(); emit openNewProjectDialog(); } void QtStartScreen::handleOpenProjectButton() { - this->hide(); emit openOpenProjectDialog(); } + +void QtStartScreen::handleRecentButton() +{ + emit finished(); +} diff --git a/src/app/qt/element/QtStartScreen.h b/src/app/qt/element/QtStartScreen.h index 8983717a..82445dbc 100644 --- a/src/app/qt/element/QtStartScreen.h +++ b/src/app/qt/element/QtStartScreen.h @@ -4,7 +4,8 @@ #include #include "QtSettingsWindow.h" -class QtRecentProjectButton : public QPushButton +class QtRecentProjectButton + : public QPushButton { Q_OBJECT public: @@ -15,7 +16,8 @@ private: std::string m_projectFile; }; -class QtStartScreen : public QtSettingsWindow +class QtStartScreen + : public QtSettingsWindow { Q_OBJECT @@ -27,10 +29,13 @@ public: signals: void openOpenProjectDialog(); void openNewProjectDialog(); + void finished(); private slots: void handleNewProjectButton(); void handleOpenProjectButton(); + void handleRecentButton(); + private: QPushButton* m_openProjectButton; QPushButton* m_newProjectButton; diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index d1822061..1ae8176a 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -67,20 +67,6 @@ void Application::loadProject(const std::string& projectSettingsFilePath) updateRecentProjects(projectSettingsFilePath); } -void Application::loadSource(const std::string& sourceDirectoryPath) -{ - MessageStatus("Loading Source: " + sourceDirectoryPath).dispatch(); - - m_storageCache->clear(); - m_componentManager->refreshViews(); - - m_project = Project::create(m_storageCache.get()); - - m_project->clearProjectSettings(); - m_project->setSourceDirectoryPath(sourceDirectoryPath); - m_project->parseCode(); -} - void Application::reloadProject() { MessageStatus("Refreshing Project").dispatch(); @@ -136,12 +122,6 @@ void Application::handleMessage(MessageLoadProject* message) loadProject(message->projectSettingsFilePath); } -void Application::handleMessage(MessageLoadSource* message) -{ - m_isInitialParse = true; - loadSource(message->sourceDirectoryPath); -} - void Application::handleMessage(MessageRefresh* message) { loadSettings(); diff --git a/src/lib/Application.h b/src/lib/Application.h index 0508ea90..47b78b52 100644 --- a/src/lib/Application.h +++ b/src/lib/Application.h @@ -8,7 +8,6 @@ #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/MessageFinishedParsing.h" #include "utility/messaging/type/MessageLoadProject.h" -#include "utility/messaging/type/MessageLoadSource.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageSaveProject.h" @@ -19,7 +18,6 @@ class StorageCache; class Application : public MessageListener , public MessageListener - , public MessageListener , public MessageListener , public MessageListener { @@ -39,7 +37,6 @@ private: virtual void handleMessage(MessageFinishedParsing* message); virtual void handleMessage(MessageLoadProject* message); - virtual void handleMessage(MessageLoadSource* message); virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageSaveProject* message); diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 6977759b..166ade22 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -247,7 +247,6 @@ add_files( utility/messaging/type/MessageGraphNodeMove.h utility/messaging/type/MessageInterruptTasks.h utility/messaging/type/MessageLoadProject.h - utility/messaging/type/MessageLoadSource.h utility/messaging/type/MessageRedo.h utility/messaging/type/MessageRefresh.h utility/messaging/type/MessageSaveProject.h diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index 2bc8d5dc..1747226d 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -70,20 +70,6 @@ void Project::reloadProjectSettings() } } -bool Project::setSourceDirectoryPath(const std::string& sourceDirectoryPath) -{ - m_projectSettingsFilepath = sourceDirectoryPath + "/ProjectSettings.xml"; - bool success = ProjectSettings::getInstance()->setSourcePaths(std::vector(1, sourceDirectoryPath)); - - if (success) - { - m_fileManager.reset(); - updateFileManager(); - } - - return success; -} - void Project::clearStorage() { m_storage = std::make_shared(); diff --git a/src/lib/Project.h b/src/lib/Project.h index 25a09880..ae05fb48 100644 --- a/src/lib/Project.h +++ b/src/lib/Project.h @@ -22,8 +22,6 @@ public: void clearProjectSettings(); void reloadProjectSettings(); - bool setSourceDirectoryPath(const std::string& sourceDirectoryPath); - void clearStorage(); void parseCode(); diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index 072b7e20..9950a274 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -84,11 +84,6 @@ void UndoRedoController::handleMessage(MessageLoadProject* message) clear(); } -void UndoRedoController::handleMessage(MessageLoadSource* message) -{ - clear(); -} - void UndoRedoController::handleMessage(MessageRedo* message) { if (!m_redo.empty()) diff --git a/src/lib/component/controller/UndoRedoController.h b/src/lib/component/controller/UndoRedoController.h index c5226fba..b00f2a57 100644 --- a/src/lib/component/controller/UndoRedoController.h +++ b/src/lib/component/controller/UndoRedoController.h @@ -12,7 +12,6 @@ #include "utility/messaging/type/MessageGraphNodeExpand.h" #include "utility/messaging/type/MessageGraphNodeMove.h" #include "utility/messaging/type/MessageLoadProject.h" -#include "utility/messaging/type/MessageLoadSource.h" #include "utility/messaging/type/MessageRedo.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageSearch.h" @@ -33,7 +32,6 @@ class UndoRedoController , public MessageListener , public MessageListener , public MessageListener - , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -63,7 +61,6 @@ private: virtual void handleMessage(MessageGraphNodeExpand* message); virtual void handleMessage(MessageGraphNodeMove* message); virtual void handleMessage(MessageLoadProject* message); - virtual void handleMessage(MessageLoadSource* message); virtual void handleMessage(MessageRedo* message); virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageSearch* message); diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index dc6a9a98..23b47465 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -809,6 +809,11 @@ std::shared_ptr Storage::getTokenLocationsForLinesInFile( std::shared_ptr ret = std::make_shared(filePath); std::shared_ptr locationFile = m_sqliteStorage.getTokenLocationsForFile(filePath); + if (!locationFile->getTokenLocationLines().size()) + { + return ret; + } + uint endLineNumber = locationFile->getTokenLocationLines().rbegin()->first; std::set addedLocationIds; for (uint i = firstLineNumber; i <= endLineNumber; i++) diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index 1d4080d4..486fb561 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -1,5 +1,22 @@ #include "settings/ProjectSettings.h" +std::vector ProjectSettings::getDefaultHeaderExtensions() +{ + std::vector defaultValues; + defaultValues.push_back(".h"); + defaultValues.push_back(".hpp"); + return defaultValues; +} + +std::vector ProjectSettings::getDefaultSourceExtensions() +{ + std::vector defaultValues; + defaultValues.push_back(".cpp"); + defaultValues.push_back(".cxx"); + defaultValues.push_back(".cc"); + return defaultValues; +} + std::shared_ptr ProjectSettings::s_instance; std::shared_ptr ProjectSettings::getInstance() @@ -67,16 +84,12 @@ std::vector ProjectSettings::getCompilerFlags() const std::vector ProjectSettings::getHeaderExtensions() const { - std::vector defaultValues; - defaultValues.push_back(".h"); - return getValues("source/Extensions/HeaderExtensions", defaultValues); + return getValues("source/Extensions/HeaderExtensions", getDefaultHeaderExtensions()); } std::vector ProjectSettings::getSourceExtensions() const { - std::vector defaultValues; - defaultValues.push_back(".cpp"); - return getValues("source/Extensions/SourceExtensions", defaultValues); + return getValues("source/Extensions/SourceExtensions", getDefaultSourceExtensions()); } bool ProjectSettings::setHeaderExtensions(const std::vector &headerExtensions) diff --git a/src/lib/settings/ProjectSettings.h b/src/lib/settings/ProjectSettings.h index 9b772c7c..5773d75e 100644 --- a/src/lib/settings/ProjectSettings.h +++ b/src/lib/settings/ProjectSettings.h @@ -10,6 +10,9 @@ class ProjectSettings : public Settings { public: + static std::vector getDefaultHeaderExtensions(); + static std::vector getDefaultSourceExtensions(); + static std::shared_ptr getInstance(); ~ProjectSettings(); diff --git a/src/lib/settings/Settings.cpp b/src/lib/settings/Settings.cpp index 833b99ec..7dd09a46 100644 --- a/src/lib/settings/Settings.cpp +++ b/src/lib/settings/Settings.cpp @@ -57,16 +57,16 @@ void Settings::clear() m_filePath = FilePath(); } -Settings::Settings() -{ - clear(); -} - const FilePath& Settings::getFilePath() const { return m_filePath; } +Settings::Settings() +{ + clear(); +} + void Settings::setFilePath(const FilePath& filePath) { m_filePath = filePath; diff --git a/src/lib/settings/Settings.h b/src/lib/settings/Settings.h index e0d42974..c6216025 100644 --- a/src/lib/settings/Settings.h +++ b/src/lib/settings/Settings.h @@ -18,10 +18,11 @@ public: virtual void save(const FilePath& filePath); void clear(); + const FilePath& getFilePath() const; + protected: Settings(); - const FilePath& getFilePath() const; void setFilePath(const FilePath& filePath); template diff --git a/src/lib/utility/messaging/type/MessageLoadSource.h b/src/lib/utility/messaging/type/MessageLoadSource.h deleted file mode 100644 index 1b7260e6..00000000 --- a/src/lib/utility/messaging/type/MessageLoadSource.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef MESSAGE_LOAD_SOURCE_H -#define MESSAGE_LOAD_SOURCE_H - -#include "utility/messaging/Message.h" - -class MessageLoadSource: public Message -{ -public: - MessageLoadSource(const std::string& sourceDir) - : sourceDirectoryPath(sourceDir) - { - } - - static const std::string getStaticType() - { - return "MessageLoadSource"; - } - - const std::string sourceDirectoryPath; -}; - -#endif // MESSAGE_LOAD_SOURCE_H