ui: reworked StartScreen and ProjectSettupScreen UI flow
* realigned buttons and elements * fixed retina styles for mac * removed MessageLoadSource and subsequent functionality * edit existing project through menu * browsing paths from the line item in QtDirectoryListBox * grow QtDirectoryListBox instead of scroll * take any file or directory as valid path * fixed new project setup screen background * fixed screen handling on cancelation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 54 KiB |
@@ -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:tool_tip/background>;
|
||||
color: <color:tool_tip/text>;
|
||||
font-size: <setting:font_size>pt;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,46 +3,113 @@
|
||||
#include <QBoxLayout>
|
||||
#include <QTreeView>
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QMimeData>
|
||||
|
||||
#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<FilePath> QtDirectoryListBox::getList()
|
||||
{
|
||||
std::vector<FilePath> 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<QtListItemWidget*>(m_list->itemWidget(m_list->item(i)));
|
||||
list.push_back(widget->getText().toStdString());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void QtDirectoryListBox::addListBoxItem()
|
||||
void QtDirectoryListBox::setList(const std::vector<FilePath>& 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<QListView*>("listView");
|
||||
if (l)
|
||||
{
|
||||
l->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
}
|
||||
QTreeView *t = dialog.findChild<QTreeView*>();
|
||||
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)
|
||||
|
||||
@@ -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 <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
#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<FilePath> getList();
|
||||
void setList(const std::vector<FilePath>& 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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef QT_LINE_EDIT_H
|
||||
#define QT_LINE_EDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class QtLineEdit
|
||||
: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtLineEdit(QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void focus();
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent* event);
|
||||
};
|
||||
|
||||
#endif // QT_LINE_EDIT_H
|
||||
@@ -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<QtStartScreen>(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<QtStartScreen>(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<QtProjectSetupScreen>(this);
|
||||
m_newProjectDialog->setup();
|
||||
if (m_startScreen)
|
||||
{
|
||||
m_startScreen->hide();
|
||||
}
|
||||
|
||||
if (!m_newProjectDialog)
|
||||
{
|
||||
m_newProjectDialog = std::make_shared<QtProjectSetupScreen>(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);
|
||||
}
|
||||
|
||||
@@ -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<std::pair<View*, QDockWidget*>> m_dockWidgets;
|
||||
|
||||
QShortcut* m_escapeShortcut;
|
||||
|
||||
bool m_startScreenWasVisible;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_WINDOW_H
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollArea>
|
||||
#include <QSysInfo>
|
||||
|
||||
|
||||
#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
|
||||
|
||||
@@ -1,51 +1,72 @@
|
||||
#ifndef QTPROJECTSETUPSCREEN_H
|
||||
#define QTPROJECTSETUPSCREEN_H
|
||||
#ifndef QT_PROJECT_SETUP_SCREEN_H
|
||||
#define QT_PROJECT_SETUP_SCREEN_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
#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<std::string> compilerFlags;
|
||||
std::vector<std::string> sourceExtensions;
|
||||
std::vector<std::string> 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
|
||||
|
||||
@@ -1,48 +1,54 @@
|
||||
#include "qt/element/QtSettingsWindow.h"
|
||||
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QSysInfo>
|
||||
|
||||
#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)
|
||||
|
||||
@@ -1,31 +1,34 @@
|
||||
#ifndef QTSETTINGSWINDOW_H
|
||||
#define QTSETTINGSWINDOW_H
|
||||
#ifndef QT_SETTINGS_WINDOW_H
|
||||
#define QT_SETTINGS_WINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QResizeEvent>
|
||||
#include <QWidget>
|
||||
|
||||
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
|
||||
|
||||
@@ -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<std::string> 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();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include <QtWidgets/qpushbutton.h>
|
||||
#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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<MessageFinishedParsing>
|
||||
, public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageLoadSource>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageSaveProject>
|
||||
{
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<FilePath>(1, sourceDirectoryPath));
|
||||
|
||||
if (success)
|
||||
{
|
||||
m_fileManager.reset();
|
||||
updateFileManager();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void Project::clearStorage()
|
||||
{
|
||||
m_storage = std::make_shared<Storage>();
|
||||
|
||||
@@ -22,8 +22,6 @@ public:
|
||||
void clearProjectSettings();
|
||||
void reloadProjectSettings();
|
||||
|
||||
bool setSourceDirectoryPath(const std::string& sourceDirectoryPath);
|
||||
|
||||
void clearStorage();
|
||||
void parseCode();
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageGraphNodeMove>
|
||||
, public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageLoadSource>
|
||||
, public MessageListener<MessageRedo>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageSearch>
|
||||
@@ -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);
|
||||
|
||||
@@ -809,6 +809,11 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationsForLinesInFile(
|
||||
std::shared_ptr<TokenLocationFile> ret = std::make_shared<TokenLocationFile>(filePath);
|
||||
|
||||
std::shared_ptr<TokenLocationFile> locationFile = m_sqliteStorage.getTokenLocationsForFile(filePath);
|
||||
if (!locationFile->getTokenLocationLines().size())
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint endLineNumber = locationFile->getTokenLocationLines().rbegin()->first;
|
||||
std::set<int> addedLocationIds;
|
||||
for (uint i = firstLineNumber; i <= endLineNumber; i++)
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultHeaderExtensions()
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".h");
|
||||
defaultValues.push_back(".hpp");
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultSourceExtensions()
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::s_instance;
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::getInstance()
|
||||
@@ -67,16 +84,12 @@ std::vector<std::string> ProjectSettings::getCompilerFlags() const
|
||||
|
||||
std::vector<std::string> ProjectSettings::getHeaderExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".h");
|
||||
return getValues("source/Extensions/HeaderExtensions", defaultValues);
|
||||
return getValues("source/Extensions/HeaderExtensions", getDefaultHeaderExtensions());
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".cpp");
|
||||
return getValues("source/Extensions/SourceExtensions", defaultValues);
|
||||
return getValues("source/Extensions/SourceExtensions", getDefaultSourceExtensions());
|
||||
}
|
||||
|
||||
bool ProjectSettings::setHeaderExtensions(const std::vector<std::string> &headerExtensions)
|
||||
|
||||
@@ -10,6 +10,9 @@ class ProjectSettings
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getDefaultHeaderExtensions();
|
||||
static std::vector<std::string> getDefaultSourceExtensions();
|
||||
|
||||
static std::shared_ptr<ProjectSettings> getInstance();
|
||||
~ProjectSettings();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<typename T>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef MESSAGE_LOAD_SOURCE_H
|
||||
#define MESSAGE_LOAD_SOURCE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageLoadSource: public Message<MessageLoadSource>
|
||||
{
|
||||
public:
|
||||
MessageLoadSource(const std::string& sourceDir)
|
||||
: sourceDirectoryPath(sourceDir)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageLoadSource";
|
||||
}
|
||||
|
||||
const std::string sourceDirectoryPath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_LOAD_SOURCE_H
|
||||
Reference in New Issue
Block a user