diff --git a/.gitignore b/.gitignore index 65b688eb..169c581d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /bin/test/data/TestSettings.xml .DS_Store +.idea diff --git a/CMakeLists.txt b/CMakeLists.txt index 61dce226..9e191484 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,16 @@ project(${PROJECT_NAME}) # Clang ------------------------------------------------------------------------ -find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build/share/llvm/cmake") +if(UNIX AND NOT APPLE) + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build_release/share/llvm/cmake") + else() + find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build_debug/share/llvm/cmake") + endif() +else() + find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build/share/llvm/cmake") +endif() + find_package(CLANG REQUIRED PATHS "${CMAKE_SOURCE_DIR}/cmake") add_definitions(${CLANG_DEFINITIONS}) @@ -110,6 +119,15 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_PREFIX_PATH "$ENV{QT_DIR}/") find_package(Qt5Widgets) + +if(Qt5Widgets_FOUND) + MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") + # FIX: Qt was built with -reduce-relocations + if (Qt5_POSITION_INDEPENDENT_CODE) + SET(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() +endif() + find_package(Qt5PrintSupport) if (WIN32) file(WRITE ${CMAKE_SOURCE_DIR}/build/Coati.rc diff --git a/bin/app/data/gui/settingwindows/listbox.css b/bin/app/data/gui/settingwindows/listbox.css new file mode 100644 index 00000000..89782c7a --- /dev/null +++ b/bin/app/data/gui/settingwindows/listbox.css @@ -0,0 +1,27 @@ +.QtDirectoryListBox { + border: 1px solid lightgray; + border-radius: 15px; + background-color: rgba(255, 255, 255, 200); +} + +.QListWidget { + border: none; + background: transparent; +} + +#roundedButton { + font-size: 15px; + color: white; + border-radius: 10px; + background: dimgray; + width: 20px; + height: 20px; +} + +#roundedButton:hover { + background: lightgray; +} + +#dropInfo { + color: lightgray; +} diff --git a/bin/app/data/gui/settingwindows/projectsetup.css b/bin/app/data/gui/settingwindows/projectsetup.css new file mode 100644 index 00000000..38a9ffe8 --- /dev/null +++ b/bin/app/data/gui/settingwindows/projectsetup.css @@ -0,0 +1,39 @@ +QLineEdit { + border-radius: 10px; + border: 1px solid lightgrey; + background-color: rgba(255, 255, 255, 200); +} + +#form { + background-color: rgba(255, 255, 255, 200); + border: none; +} + +#moreButton { + font-size: 15px; + margin-left: 10px; + color: gray; + border-radius: 10px; + border: 1px solid lightgray; + background: white; + width: 40px; + height: 20px; +} + +#moreutton:hover { + background: lightgray; +} + +#windowButton { + margin-left: 10px; + color: black; + border-radius: 10px; + border: 1px solid lightgray; + background: white; + width: 40px; + height: 20px; +} + +#windowButton:hover { + background: lightgray; +} diff --git a/bin/app/data/gui/startscreen/Icon_CPP.png b/bin/app/data/gui/startscreen/Icon_CPP.png new file mode 100644 index 00000000..1ce2a01f Binary files /dev/null and b/bin/app/data/gui/startscreen/Icon_CPP.png differ diff --git a/bin/app/data/gui/startscreen/icon_file.png b/bin/app/data/gui/startscreen/icon_file.png new file mode 100644 index 00000000..f41fe71c Binary files /dev/null and b/bin/app/data/gui/startscreen/icon_file.png differ diff --git a/bin/app/data/gui/startscreen/logo.png b/bin/app/data/gui/startscreen/logo.png new file mode 100755 index 00000000..2c45335a Binary files /dev/null and b/bin/app/data/gui/startscreen/logo.png differ diff --git a/bin/app/data/gui/startscreen/logo_schriftzug.png b/bin/app/data/gui/startscreen/logo_schriftzug.png new file mode 100755 index 00000000..02807313 Binary files /dev/null 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 new file mode 100644 index 00000000..c59555ff --- /dev/null +++ b/bin/app/data/gui/startscreen/startscreen.css @@ -0,0 +1,28 @@ +#projectButton { + font-size: 17pt; + border: 1px solid lightgray; + border-radius: 10px; + background: white; +} + +#projectButton:hover { + color: white; + background: navy; +} + +#recentButton{ + font-size: 12pt; + color: black; + background: none; + border: none; +} + +#recentButton:hover{ + background: lightgray; + border-radius: 10px; +} + +#recentLabel { + font-size: 16pt; + color: black; +} diff --git a/cmake/CLANGConfig.cmake b/cmake/CLANGConfig.cmake index cba3b8c9..ea3260c5 100644 --- a/cmake/CLANGConfig.cmake +++ b/cmake/CLANGConfig.cmake @@ -1,21 +1,43 @@ -execute_process( - COMMAND $ENV{CLANG_DIR}/build/bin/llvm-config --cxxflags - OUTPUT_VARIABLE CLANG_DEFINITIONS -) +if(UNIX AND NOT APPLE) -set(CLANG_INCLUDE_DIRS - "$ENV{CLANG_DIR}/llvm/tools/clang/include" - "$ENV{CLANG_DIR}/build/tools/clang/include" -) + execute_process( + COMMAND $ENV{CLANG_DIR}/build_debug/bin/llvm-config --cxxflags + OUTPUT_VARIABLE CLANG_DEFINITIONS + ) -set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build/lib") -if (UNIX) - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build/Release+Asserts/lib") - endif() -endif () + set(CLANG_INCLUDE_DIRS + "$ENV{CLANG_DIR}/llvm/tools/clang/include" + "$ENV{CLANG_DIR}/build_debug/tools/clang/include" + ) + set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build_debug/lib") + if (UNIX) + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build_release/lib") + endif() + endif () + +else() + + execute_process( + COMMAND $ENV{CLANG_DIR}/build/bin/llvm-config --cxxflags + OUTPUT_VARIABLE CLANG_DEFINITIONS + ) + + set(CLANG_INCLUDE_DIRS + "$ENV{CLANG_DIR}/llvm/tools/clang/include" + "$ENV{CLANG_DIR}/build/tools/clang/include" + ) + + set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build_debug/lib") + if (UNIX) + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build/Release+Asserts/lib") + endif() + endif () + +endif() set(CLANG_LIBRARIES #clangApplyReplacements diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 868937dc..0c42b3b7 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -15,12 +15,18 @@ add_files( qt/element/QtCodeFileList.h qt/element/QtCodeSnippet.cpp qt/element/QtCodeSnippet.h + qt/element/QtDirectoryListBox.cpp + qt/element/QtDirectoryListBox.h qt/element/QtMainWindow.cpp qt/element/QtMainWindow.h + qt/element/QtProjectSetupScreen.cpp + qt/element/QtProjectSetupScreen.h qt/element/QtRefreshBar.cpp qt/element/QtRefreshBar.h qt/element/QtSearchBar.cpp qt/element/QtSearchBar.h + qt/element/QtSettingsWindow.cpp + qt/element/QtSettingsWindow.h qt/element/QtSmartSearchBox.cpp qt/element/QtSmartSearchBox.h qt/element/QtSplashScreen.cpp diff --git a/src/app/qt/element/QtDirectoryListBox.cpp b/src/app/qt/element/QtDirectoryListBox.cpp new file mode 100644 index 00000000..c763aa86 --- /dev/null +++ b/src/app/qt/element/QtDirectoryListBox.cpp @@ -0,0 +1,122 @@ +#include "qt/element/QtDirectoryListBox.h" + +#include +#include +#include +#include +#include + +#include "qt/utility/utilityQt.h" + +QtDirectoryListBox::QtDirectoryListBox(QWidget *parent) + :QFrame(parent) +{ + setObjectName("QtListBox"); + setMinimumHeight(150); + QBoxLayout* layout = new QVBoxLayout(); + layout->setSpacing(0); + layout->setContentsMargins(10, 10, 10, 10); + layout->setAlignment(Qt::AlignTop); + m_list = new QListWidget(this); + + 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); + + m_addButton = new QPushButton("+",this); + m_addButton->resize(20,20); + m_addButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + 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->setObjectName("roundedButton"); + innerLayout->addWidget(m_removeButton); + + QLabel* dropInfoText = new QLabel("You can drop Folders here"); + dropInfoText->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + dropInfoText->setObjectName("dropInfo"); + dropInfoText->setAlignment(Qt::AlignRight); + innerLayout->addWidget(dropInfoText); + buttonContainer->setLayout(innerLayout); + layout->addWidget(buttonContainer); + setLayout(layout); + + connect(m_addButton, SIGNAL(clicked()), this, SLOT(addListBoxItem())); + connect(m_removeButton, SIGNAL(clicked()), this, SLOT(removeListBoxItem())); + + setAcceptDrops(true); +} + +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()); + } + } +} + +std::vector QtDirectoryListBox::getList() +{ + std::vector list; + for( int i = 0; i < m_list->count(); ++i) + { + QListWidgetItem* item = m_list->item(i); + list.push_back(item->text().toStdString()); + } + + return list; +} + +void QtDirectoryListBox::addListBoxItem() +{ + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::DirectoryOnly); + dialog.setOption(QFileDialog::ShowDirsOnly, true); + dialog.setOption(QFileDialog::DontUseNativeDialog,true); + + // 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()) + { + 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)); + } + } +} + +void QtDirectoryListBox::removeListBoxItem() +{ + qDeleteAll(m_list->selectedItems()); +} + +void QtDirectoryListBox::dragEnterEvent(QDragEnterEvent *event) +{ + event->accept(); +} diff --git a/src/app/qt/element/QtDirectoryListBox.h b/src/app/qt/element/QtDirectoryListBox.h new file mode 100644 index 00000000..33f1c732 --- /dev/null +++ b/src/app/qt/element/QtDirectoryListBox.h @@ -0,0 +1,30 @@ +#ifndef QT_DIRECTORYLISTBOX_H +#define QT_DIRECTORYLISTBOX_H + +#include +#include +#include +#include + +#include "utility/file/FilePath.h" + +class QtDirectoryListBox : public QFrame +{ +Q_OBJECT +public: + QtDirectoryListBox(QWidget *parent); + std::vector getList(); +protected: + void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent* event); +private: + QPushButton* m_addButton; + QPushButton* m_removeButton; + QListWidget* m_list; + +private slots: + void addListBoxItem(); + void removeListBoxItem(); +}; + +#endif //QT_DIRECTORYLISTBOX_H diff --git a/src/app/qt/element/QtMainWindow.cpp b/src/app/qt/element/QtMainWindow.cpp index f16776ba..3990b3d8 100644 --- a/src/app/qt/element/QtMainWindow.cpp +++ b/src/app/qt/element/QtMainWindow.cpp @@ -9,7 +9,6 @@ #include "component/view/View.h" #include "component/view/CompositeView.h" -#include "qt/element/QtStartScreen.h" #include "qt/view/QtViewWidgetWrapper.h" #include "utility/logging/logging.h" #include "utility/messaging/type/MessageFind.h" @@ -31,6 +30,7 @@ QtMainWindow::QtMainWindow() setDockNestingEnabled(true); setWindowIcon(QIcon("./data/gui/icon/logo_1024_1024.png")); + setWindowFlags(Qt::Widget); QApplication::setOverrideCursor(Qt::ArrowCursor); @@ -44,13 +44,17 @@ QtMainWindow::QtMainWindow() // Need to call loadLayout here for right DockWidget size on Linux // Seconde call is in Application.cpp loadLayout(); +} +void QtMainWindow::init() +{ // StartScreen m_startScreen = std::make_shared(this); - m_startScreen->setWindowModality(Qt::WindowModal); + m_startScreen->setup(); m_startScreen->show(); } + QtMainWindow::~QtMainWindow() { } @@ -60,8 +64,8 @@ void QtMainWindow::addView(View* view) QDockWidget* dock = new QDockWidget(tr(view->getName().c_str()), this); dock->setWidget(QtViewWidgetWrapper::getWidgetOfView(view)); dock->setObjectName(QString::fromStdString("Dock" + view->getName())); - // dock->setFeatures(QDockWidget::NoDockWidgetFeatures); - // dock->setTitleBarWidget(new QWidget()); + //dock->setFeatures(QDockWidget::NoDockWidgetFeatures); + //dock->setTitleBarWidget(new QWidget()); addDockWidget(Qt::TopDockWidgetArea, dock); m_dockWidgets.push_back(std::make_pair(view, dock)); } @@ -149,12 +153,9 @@ void QtMainWindow::about() void QtMainWindow::newProject() { - QString sourceDir = QFileDialog::getExistingDirectory(this, tr("Open Directory")); - - if (!sourceDir.isEmpty()) - { - MessageLoadSource(sourceDir.toStdString()).dispatch(); - } + m_newProjectDialog = std::make_shared(this); + m_newProjectDialog->setup(); + m_newProjectDialog->show(); } void QtMainWindow::openProject(const QString &path) @@ -241,7 +242,14 @@ void QtMainWindow::switchColorScheme() void QtMainWindow::handleEscapeShortcut() { - m_startScreen->hide(); + if(m_startScreen) + { + m_startScreen->hide(); + } + if(m_newProjectDialog) + { + m_newProjectDialog->hide(); + } MessageInterruptTasks().dispatch(); } diff --git a/src/app/qt/element/QtMainWindow.h b/src/app/qt/element/QtMainWindow.h index ccf01a14..907fe9b8 100644 --- a/src/app/qt/element/QtMainWindow.h +++ b/src/app/qt/element/QtMainWindow.h @@ -9,6 +9,7 @@ #include #include "QtStartScreen.h" +#include "QtProjectSetupScreen.h" class QDockWidget; class View; @@ -21,6 +22,8 @@ public: QtMainWindow(); ~QtMainWindow(); + void init(); + void addView(View* view); void removeView(View* view); @@ -62,6 +65,7 @@ private: QDockWidget* getDockWidgetForView(View* view) const; std::shared_ptr m_startScreen; + std::shared_ptr m_newProjectDialog; std::vector> m_dockWidgets; diff --git a/src/app/qt/element/QtProjectSetupScreen.cpp b/src/app/qt/element/QtProjectSetupScreen.cpp new file mode 100644 index 00000000..59be4c67 --- /dev/null +++ b/src/app/qt/element/QtProjectSetupScreen.cpp @@ -0,0 +1,185 @@ +#include "qt/element/QtProjectSetupScreen.h" + +#include +#include +#include +#include +#include +#include +#include + + +#include "settings/ProjectSettings.h" +#include "utility/logging/logging.h" +#include "qt/utility/QtDeviceScaledPixmap.h" +#include "utility/messaging/type/MessageLoadProject.h" +#include "qt/utility/utilityQt.h" + +QtTextLine::QtTextLine(QWidget *parent) + :QWidget(parent) +{ + QBoxLayout* layout = new QHBoxLayout(); + layout->setSpacing(0); + layout->setContentsMargins(1, 1, 1, 1); + layout->setAlignment(Qt::AlignTop); + + setLayout(layout); + + m_data = new QLineEdit(this); + 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())); +} + +QString QtTextLine::getText() +{ + return m_data->text(); +} + +void QtTextLine::setText(QString text) +{ + m_data->setText(text); +} + +void QtTextLine::handleButtonPress() +{ + QString file = QFileDialog::getExistingDirectory(this, tr("Select File"), ""); + if (!file.isEmpty()) + { + m_data->setText(file); + } +} + +QtProjectSetupScreen::QtProjectSetupScreen(QWidget *parent) + : QtSettingsWindow(parent) +{ + raise(); +} + +void QtProjectSetupScreen::setup() +{ + 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->addSpacing(30); + + QScrollArea* scrollArea = new QScrollArea(); + scrollArea->setObjectName("coatiBackground"); + 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); + + QLabel* nameLabel = new QLabel("Name"); + m_projectName = new QLineEdit(); + layout->addRow(nameLabel, m_projectName); + + QLabel* locationLabel = new QLabel("Location"); + m_projectFileLocation = new QtTextLine(this); + 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"); + m_sourcePaths = new QtDirectoryListBox(this); + layout->addRow(sourcePathsLabel, m_sourcePaths); + + QLabel* includePathsLabel = new QLabel("IncludePaths"); + m_includePaths = new QtDirectoryListBox(this); + layout->addRow(includePathsLabel, m_includePaths); + + if(QSysInfo::macVersion() != QSysInfo::MV_None) + { + QLabel* frameworkPathsLabel = new QLabel("FrameworkPaths"); + m_frameworkPaths = new QtDirectoryListBox(this); + layout->addRow(frameworkPathsLabel, m_frameworkPaths); + } + form->setLayout(layout); + + QPushButton* createButton = new QPushButton("Create"); + createButton->setObjectName("windowButton"); + QPushButton* cancelButton = new QPushButton("Cancel"); + cancelButton->setObjectName("windowButton"); + + connect(createButton, SIGNAL(clicked()), this, SLOT(handleCreateButtonPress())); + connect(cancelButton, SIGNAL(clicked()), this, SLOT(handleCancelButtonPress())); + + QHBoxLayout* buttons = new QHBoxLayout(); + buttons->addSpacing(100); + buttons->addWidget(createButton); + buttons->addWidget(cancelButton); + buttons->addSpacing(30); + + windowLayout->addWidget(scrollArea); + windowLayout->addSpacing(20); + windowLayout->addLayout(buttons); + + m_window->setLayout(windowLayout); + resize(QSize(600,600)); +} + +void QtProjectSetupScreen::handleCancelButtonPress() +{ + hide(); +} + +void QtProjectSetupScreen::handleCreateButtonPress() +{ + bool error = false; + if(m_projectName->text().isEmpty()) + { + QMessageBox msgBox; + 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; + } + + if(!error) + { + 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(); + } +} + +QSize QtProjectSetupScreen::sizeHint() const +{ + return QSize(600,600); +} diff --git a/src/app/qt/element/QtProjectSetupScreen.h b/src/app/qt/element/QtProjectSetupScreen.h new file mode 100644 index 00000000..47428ee2 --- /dev/null +++ b/src/app/qt/element/QtProjectSetupScreen.h @@ -0,0 +1,51 @@ +#ifndef QTPROJECTSETUPSCREEN_H +#define QTPROJECTSETUPSCREEN_H + +#include +#include +#include +#include + +#include "QtSettingsWindow.h" + +#include "qt/element/QtDirectoryListBox.h" +#include "utility/file/FilePath.h" + +class QtTextLine : public QWidget +{ +Q_OBJECT +public: + QtTextLine(QWidget *parent); + QString getText(); + void setText(QString text); +private: + QPushButton* m_button; + QLineEdit* m_data; +private slots: + void handleButtonPress(); +}; + +class QtProjectSetupScreen : public QtSettingsWindow +{ +Q_OBJECT +public: + QtProjectSetupScreen(QWidget* parent = 0); + QSize sizeHint() const Q_DECL_OVERRIDE; + virtual void setup(); +private slots: + void handleCreateButtonPress(); + void handleCancelButtonPress(); + +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; +}; + + +#endif //QTPROJECTSETUPSCREEN_H diff --git a/src/app/qt/element/QtSettingsWindow.cpp b/src/app/qt/element/QtSettingsWindow.cpp new file mode 100644 index 00000000..b6a3b48e --- /dev/null +++ b/src/app/qt/element/QtSettingsWindow.cpp @@ -0,0 +1,89 @@ +#include "qt/element/QtSettingsWindow.h" + +#include + +#include "utility/messaging/type/MessageInterruptTasks.h" + +QtSettingsWindow::QtSettingsWindow(QWidget *parent, int displacement) + : 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); + 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); + 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); " + "}"; + 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); + + this->raise(); +} + +void QtSettingsWindow::keyPressEvent(QKeyEvent *event) +{ + if(event->key() == Qt::Key_Escape) + { + this->hide(); + } +} + +QSize QtSettingsWindow::sizeHint() const +{ + return QSize(500, 500); +} + +void QtSettingsWindow::resizeEvent(QResizeEvent *event) { + QSize windowSize = event->size()-QSize(10,10+m_displacment); + m_window->resize(windowSize); + m_window->move(0,m_displacment); +} + +void QtSettingsWindow::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() & Qt::LeftButton && m_mousePressedInWindow) + { + move(event->globalPos() - m_dragPosition); + event->accept(); + } +} + +void QtSettingsWindow::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + m_dragPosition = event->globalPos() - frameGeometry().topLeft(); + event->accept(); + m_mousePressedInWindow = true; + } +} + +void QtSettingsWindow::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + m_dragPosition = event->globalPos() - frameGeometry().topLeft(); + event->accept(); + m_mousePressedInWindow = false; + } +} diff --git a/src/app/qt/element/QtSettingsWindow.h b/src/app/qt/element/QtSettingsWindow.h new file mode 100644 index 00000000..89f79b34 --- /dev/null +++ b/src/app/qt/element/QtSettingsWindow.h @@ -0,0 +1,31 @@ +#ifndef QTSETTINGSWINDOW_H +#define QTSETTINGSWINDOW_H + +#include +#include + +class QtSettingsWindow : public QWidget +{ + Q_OBJECT + +public: + QtSettingsWindow(QWidget* parent = 0, int displacement = 0); + QSize sizeHint() const Q_DECL_OVERRIDE; + virtual void setup() = 0; + +protected: + QWidget* m_window; + + void keyPressEvent(QKeyEvent* event); + void resizeEvent(QResizeEvent* event); + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; +private: + int m_displacment; + QPoint m_dragPosition; + bool m_mousePressedInWindow; + //void mouse +}; + +#endif //QTSETTINGSWINDOW_H diff --git a/src/app/qt/element/QtSplashScreen.cpp b/src/app/qt/element/QtSplashScreen.cpp index 563981df..430546b6 100644 --- a/src/app/qt/element/QtSplashScreen.cpp +++ b/src/app/qt/element/QtSplashScreen.cpp @@ -1,4 +1,4 @@ -#include "QtSplashScreen.h" +#include "qt/element/QtSplashScreen.h" #include #include diff --git a/src/app/qt/element/QtStartScreen.cpp b/src/app/qt/element/QtStartScreen.cpp index 6ef6eb69..faf32e9b 100644 --- a/src/app/qt/element/QtStartScreen.cpp +++ b/src/app/qt/element/QtStartScreen.cpp @@ -1,17 +1,22 @@ -#include "QtStartScreen.h" +#include "qt/element/QtStartScreen.h" #include +#include +#include +#include "settings/ApplicationSettings.h" #include "utility/file/FileSystem.h" #include "utility/messaging/type/MessageLoadProject.h" #include "qt/utility/QtDeviceScaledPixmap.h" +#include "qt/utility/utilityQt.h" QtRecentProjectButton::QtRecentProjectButton(const QString &text, QWidget *parent) : QPushButton(text, parent) { m_projectFile = text.toStdString(); this->setText(FileSystem::fileName(text.toStdString()).c_str()); + this->setToolTip(m_projectFile.c_str()); } void QtRecentProjectButton::handleButtonClick() @@ -21,90 +26,61 @@ void QtRecentProjectButton::handleButtonClick() }; QtStartScreen::QtStartScreen(QWidget *parent) - : QWidget(parent, Qt::Dialog | Qt::Popup | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint ) + : QtSettingsWindow(parent, 50) { - setGeometry(parent->pos().x()+parent->width()/2-250,parent->pos().y()+parent->height()/2-250,500,500); + this->raise(); +} - QPalette palette; - QLinearGradient linearGradient(QPointF(0, 275), QPointF(0, 500)); - linearGradient.setColorAt(0, QColor(46, 61, 135)); - linearGradient.setColorAt(1, QColor(0, 120, 195)); - palette.setBrush(QPalette::Window, *(new QBrush(linearGradient))); - this->setPalette(palette); - - QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo_white.png"); - coati_logo.scaleToWidth(100); +void QtStartScreen::setup() +{ + setStyleSheet(utility::getStyleSheet("data/gui/startscreen/startscreen.css").c_str()); + std::vector recentProjects = ApplicationSettings::getInstance()->getRecentProjects(); + QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo_schriftzug.png"); + coati_logo.scaleToWidth(250); QLabel* coatiLogoLabel = new QLabel(this); coatiLogoLabel->setPixmap(coati_logo.pixmap()); - coatiLogoLabel->setGeometry(30, 30, coati_logo.width(), coati_logo.height()); - - std::string buttonStyle = - "QPushButton {" - "font-size: 17pt; " - "border-radius: 10px; " - "background: white; " - "} " - "QPushButton:hover {" - "background: rgba(255, 255, 255, 0.8); " - "}"; + coatiLogoLabel->resize(coati_logo.width(), coati_logo.height()); + coatiLogoLabel->move(30,10); 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->setStyleSheet(buttonStyle.c_str()); + 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->setStyleSheet(buttonStyle.c_str()); + 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())); + 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); - recentProjectsLabel->setStyleSheet( - "QLabel {" - "font-size: 16pt; " - "color: white; " - "}" - ); - - std::vector extensions; - extensions.push_back(".xml"); - std::vector recentProjects = FileSystem::getFileNamesFromDirectory("data/projects", extensions); + recentProjectsLabel->setObjectName("recentLabel"); int position = 200; - QIcon cpp_icon("data/gui/startscreen/cpluspluss_icon.png"); + QIcon cpp_icon("data/gui/startscreen/Icon_CPP.png"); for (std::string project : recentProjects) { - QtRecentProjectButton* button = new QtRecentProjectButton(project.c_str(), this); - button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - button->setIcon(cpp_icon); - button->setIconSize(QSize(25, 25)); - button->setStyleSheet( - "QPushButton{" - "font-size: 12pt; " - // "text-align: left; " // when using this the QPixmap is drawn without regard of the screens DPI - "color: white; " - "background: none; " - "border: none; " - "} " - "QPushButton:hover{" - "background: rgba(255, 255, 255, 0.15); " - "border-radius: 10px; " - "}" - ); - button->minimumSizeHint(); // force font loading - button->setGeometry(292, position, button->fontMetrics().width(button->text()) + 45, 40); - connect(button, SIGNAL(clicked()), button, SLOT(handleButtonClick())); - position += 40; + if(FileSystem::exists(project.c_str())) + { + QtRecentProjectButton* button = new QtRecentProjectButton(project.c_str(), this); + button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac + button->setIcon(cpp_icon); + button->setIconSize(QSize(25, 25)); + button->setObjectName("recentButton"); + button->minimumSizeHint(); // force font loading + button->setGeometry(292, position, button->fontMetrics().width(button->text()) + 45, 40); + connect(button, SIGNAL(clicked()), button, SLOT(handleButtonClick())); + position += 40; + } } - this->raise(); + resize(600,500); } QSize QtStartScreen::sizeHint() const diff --git a/src/app/qt/element/QtStartScreen.h b/src/app/qt/element/QtStartScreen.h index c3422405..3a2e1d8e 100644 --- a/src/app/qt/element/QtStartScreen.h +++ b/src/app/qt/element/QtStartScreen.h @@ -1,9 +1,8 @@ #ifndef STARTSCREEN_H #define STARTSCREEN_H -#include -#include #include +#include "QtSettingsWindow.h" class QtRecentProjectButton : public QPushButton { @@ -16,13 +15,14 @@ private: std::string m_projectFile; }; -class QtStartScreen : public QWidget +class QtStartScreen : public QtSettingsWindow { Q_OBJECT public: QtStartScreen(QWidget* parent = 0); QSize sizeHint() const Q_DECL_OVERRIDE; + virtual void setup(); signals: void openOpenProjectDialog(); diff --git a/src/app/qt/view/QtMainView.cpp b/src/app/qt/view/QtMainView.cpp index 405cfcb2..5e557aab 100644 --- a/src/app/qt/view/QtMainView.cpp +++ b/src/app/qt/view/QtMainView.cpp @@ -8,6 +8,7 @@ QtMainView::QtMainView() { m_window = std::make_shared(); m_window->show(); + m_window->init(); } QtMainView::~QtMainView() diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 2548da72..2f7f81d1 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -61,9 +61,18 @@ void Application::loadProject(const std::string& projectSettingsFilePath) m_componentManager->refreshViews(); m_project = Project::create(m_storageCache.get()); - m_project->loadProjectSettings(projectSettingsFilePath); m_project->parseCode(); + + std::vector recentProjects = ApplicationSettings::getInstance()->getRecentProjects(); + recentProjects.erase(std::find(recentProjects.begin(),recentProjects.end(),projectSettingsFilePath)); + recentProjects.insert(recentProjects.begin(),projectSettingsFilePath); + if(recentProjects.size() > 7) + { + recentProjects.pop_back(); + } + ApplicationSettings::getInstance()->setRecentProjects(recentProjects); + ApplicationSettings::getInstance()->save("data/ApplicationSettings.xml"); } void Application::loadSource(const std::string& sourceDirectoryPath) diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index bf83e48f..bf878b53 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -100,3 +100,12 @@ void ApplicationSettings::setCodeSnippetExpandRange(int range) ApplicationSettings::ApplicationSettings() { } + +std::vector ApplicationSettings::getRecentProjects() const { + std::vector recentProjects; + return getValues("recentProjects/projectFilePath", recentProjects); +} + +bool ApplicationSettings::setRecentProjects(const std::vector &recentProjects) { + return setValues("recentProjects/projectFilePath", recentProjects); +} diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h index 29827381..9075e256 100644 --- a/src/lib/settings/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -29,6 +29,10 @@ public: std::string getColorSchemePath() const; void setColorSchemePath(const std::string& colorSchemePath); + //recent projects + std::vector getRecentProjects() const; + bool setRecentProjects(const std::vector& recentProjects); + // code int getCodeTabWidth() const; void setCodeTabWidth(int codeTabWidth); diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index 221f4585..1d4080d4 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -78,3 +78,13 @@ std::vector ProjectSettings::getSourceExtensions() const defaultValues.push_back(".cpp"); return getValues("source/Extensions/SourceExtensions", defaultValues); } + +bool ProjectSettings::setHeaderExtensions(const std::vector &headerExtensions) +{ + return setValues("source/Extensions/HeaderExtensions", headerExtensions); +} + +bool ProjectSettings::setSourceExtensions(const std::vector &sourceExtensions) +{ + return setValues("source/Extensions/SourceExtensions", sourceExtensions); +} diff --git a/src/lib/settings/ProjectSettings.h b/src/lib/settings/ProjectSettings.h index 4d8b0bff..9b772c7c 100644 --- a/src/lib/settings/ProjectSettings.h +++ b/src/lib/settings/ProjectSettings.h @@ -31,6 +31,9 @@ public: std::vector getHeaderExtensions() const; std::vector getSourceExtensions() const; + bool setHeaderExtensions(const std::vector& headerExtensions); + bool setSourceExtensions(const std::vector& sourceExtensions); + private: ProjectSettings(); ProjectSettings(const ProjectSettings&);