build: trial version target

builds now app and trail target, lib_gui added, istrail function
This commit is contained in:
Andreas Stallinger
2015-12-08 17:55:12 +01:00
parent ed4b6546f0
commit 43409cd6b7
154 changed files with 444 additions and 213 deletions
+112
View File
@@ -0,0 +1,112 @@
#include "qt/window/QtAbout.h"
#include <QFormLayout>
#include <QLineEdit>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "qt/utility/QtDeviceScaledPixmap.h"
#include "qt/utility/utilityQt.h"
#include "utility/Version.h"
QtAbout::QtAbout(QWidget *parent)
: QtSettingsWindow(parent)
{
raise();
}
QSize QtAbout::sizeHint() const
{
return QSize(370, 550);
}
void QtAbout::setup()
{
m_window->setStyleSheet(
m_window->styleSheet() +
"#SettingWindow { "
"background: qlineargradient( x1:0 y1:0.4, x2:0 y2:1, stop:0 #2F3F86, stop:1 #1C7BBC );"
"border: none;"
"}"
);
setStyleSheet(utility::getStyleSheet("data/gui/about/about.css").c_str());
QtDeviceScaledPixmap coatiLogo("data/gui/about/logo.png");
coatiLogo.scaleToWidth(180);
QLabel* coatiLogoLabel = new QLabel(this);
coatiLogoLabel->setPixmap(coatiLogo.pixmap());
coatiLogoLabel->resize(coatiLogo.width(), coatiLogo.height());
coatiLogoLabel->move(8, 20);
QLabel* versionLabel = new QLabel(("Version " + Version::getApplicationVersion().toDisplayString()).c_str(), this);
versionLabel->move(210, 181);
QLabel* developerTitle = new QLabel("Developed by:", this);
developerTitle->move(30, 220);
QLabel* companyLabel = new QLabel(
"Coati Software OG\n"
"Schlossallee 7/1\n"
"5412 Puch bei Hallein\n"
"Austria\n"
"support@coati.io\n",
this
);
companyLabel->move(210, 250);
QLabel* developerLabel = new QLabel(
"Manuel Dobusch\n"
"Eberhard Gräther\n"
"Malte Langkabel\n"
"Viktoria Pfausler\n"
"Andreas Stallinger\n",
this
);
developerLabel->move(30, 250);
QLabel* acknowledgementsTitle = new QLabel("Acknowledgements:", this);
acknowledgementsTitle->setObjectName("small");
acknowledgementsTitle->move(30, 355);
QLabel* acknowledgementsLabel = new QLabel(
"Coati 0.1 was created in the context of education at",
this
);
acknowledgementsLabel->setObjectName("small");
acknowledgementsLabel->move(30, 385);
QtDeviceScaledPixmap fhsLogo("data/gui/about/logo_fhs.png");
fhsLogo.scaleToWidth(150);
QLabel* fhsLabel = new QLabel(this);
fhsLabel->setPixmap(fhsLogo.pixmap());
fhsLabel->resize(fhsLogo.width(), fhsLogo.height());
fhsLabel->move(115, 410);
QLabel* acknowledgementsLabel2 = new QLabel(
"Coati Software OG takes part in the Startup Salzburg\ninitiative.",
this
);
acknowledgementsLabel2->setObjectName("small");
acknowledgementsLabel2->move(30, 465);
QPushButton* closeButton = new QPushButton("X", this);
closeButton->setObjectName("closeButton");
closeButton->move(320, 20);
connect(closeButton, SIGNAL(clicked()), this, SLOT(handleCloseButtonPress()));
}
void QtAbout::handleCloseButtonPress()
{
emit finished();
}
void QtAbout::handleCancelButtonPress()
{
}
void QtAbout::handleUpdateButtonPress()
{
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef QT_ABOUT_H
#define QT_ABOUT_H
#include <QPushButton>
#include <QWidget>
#include "qt/window/QtSettingsWindow.h"
class QtAbout
: public QtSettingsWindow
{
Q_OBJECT
public:
QtAbout(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
virtual void setup() override;
private slots:
void handleCloseButtonPress();
void handleCancelButtonPress();
void handleUpdateButtonPress();
};
#endif //QT_ABOUT_H
+65
View File
@@ -0,0 +1,65 @@
#include "qt/window/QtAboutLicense.h"
#include <QComboBox>
#include <QFormLayout>
#include <QLineEdit>
#include <QLabel>
#include <QTextBrowser>
#include <QTextBlock>
#include <QTextEdit>
#include "licenses.h"
QtAboutLicense::QtAboutLicense(QWidget *parent)
: QtSettingsWindow(parent)
{
raise();
}
QSize QtAboutLicense::sizeHint() const
{
return QSize(600,600);
}
void QtAboutLicense::setup()
{
setupForm();
updateTitle("3rd Party Licenses");
updateDoneButton("Ok");
hideCancelButton(true);
}
void QtAboutLicense::populateForm(QFormLayout* layout)
{
for(ThirdPartyLicense license : licenses3rdParties)
{
QLabel* licenseName = new QLabel();
licenseName->setText( QString::fromLatin1(license.name));
QFont _font = licenseName->font();
_font.setPixelSize(36);
licenseName->setFont(_font);
layout->addWidget(licenseName);
QLabel* licenseURL = new QLabel();
licenseURL->setText(QString::fromLatin1("(<a href=\"%1\">Website</a>)")
.arg(QString::fromLatin1(license.url)));
licenseURL->setOpenExternalLinks(true);
layout->addWidget(licenseURL);
QLabel* licenseText = new QLabel();
licenseText->setFixedWidth(450);
licenseText->setWordWrap(true);
licenseText->setText(QString::fromLatin1(license.license));
layout->addWidget(licenseText);
}
}
void QtAboutLicense::handleCancelButtonPress()
{
}
void QtAboutLicense::handleUpdateButtonPress()
{
emit finished();
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef QT_ABOUT_LICENSE_H
#define QT_ABOUT_LICENSE_H
#include <QPushButton>
#include <QWidget>
#include "qt/window/QtSettingsWindow.h"
class QtAboutLicense
: public QtSettingsWindow
{
Q_OBJECT
public:
QtAboutLicense(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
virtual void setup() override;
protected:
virtual void populateForm(QFormLayout* layout) override;
private slots:
void handleCancelButtonPress();
void handleUpdateButtonPress();
};
#endif //QT_ABOUT_LICENSE_H
@@ -0,0 +1,104 @@
#include "qt/window/QtApplicationSettingsScreen.h"
#include <QComboBox>
#include <QFormLayout>
#include <QLineEdit>
#include <QSysInfo>
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "settings/ApplicationSettings.h"
QtApplicationSettingsScreen::QtApplicationSettingsScreen(QWidget *parent)
: QtSettingsWindow(parent)
, m_frameworkPaths(nullptr)
{
raise();
}
QSize QtApplicationSettingsScreen::sizeHint() const
{
return QSize(600,600);
}
void QtApplicationSettingsScreen::setup()
{
setupForm();
updateTitle("PREFERENCES");
updateDoneButton("Save");
}
void QtApplicationSettingsScreen::load()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_includePaths->setList(appSettings->getHeaderSearchPaths());
if (m_frameworkPaths)
{
m_frameworkPaths->setList(appSettings->getFrameworkSearchPaths());
}
}
void QtApplicationSettingsScreen::populateForm(QFormLayout* layout)
{
int minimumWidthForSecondCol = 360;
QPushButton* helpButton;
QWidget* includePathsWidget = createLabelWithHelpButton("Header\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleIncludePathHelpPress()));
m_includePaths = new QtDirectoryListBox(this);
m_includePaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(includePathsWidget, m_includePaths);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
QWidget* frameworkPathsWidget = createLabelWithHelpButton("Framework\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleFrameworkPathHelpPress()));
m_frameworkPaths = new QtDirectoryListBox(this);
m_frameworkPaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(frameworkPathsWidget, m_frameworkPaths);
}
}
void QtApplicationSettingsScreen::handleCancelButtonPress()
{
emit canceled();
}
void QtApplicationSettingsScreen::handleUpdateButtonPress()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
appSettings->setHeaderSearchPaths(m_includePaths->getList());
if (m_frameworkPaths)
{
appSettings->setFrameworkSearchPaths(m_frameworkPaths->getList());
}
appSettings->save();
MessageRefresh().dispatch();
emit finished();
}
void QtApplicationSettingsScreen::handleIncludePathHelpPress()
{
showHelpMessage(
"Header Search Paths define where additional headers, that your project depends on, are found. Usually they are "
"header files of frameworks or libraries that your project uses. These files won't be analysed, but Coati needs "
"them for correct analysis.\n\n"
"Header Search Paths defined here will be used for all projects."
);
}
void QtApplicationSettingsScreen::handleFrameworkPathHelpPress()
{
showHelpMessage(
"Framework Search Paths define where MacOS framework containers, that your project depends on, are found.\n\n"
"Framework Search Paths defined here will be used for all projects."
);
}
@@ -0,0 +1,43 @@
#ifndef QT_APPLICATION_SETTINGS_SCREEN_H
#define QT_APPLICATION_SETTINGS_SCREEN_H
#include <QPushButton>
#include <QWidget>
#include "utility/file/FilePath.h"
#include "qt/element/QtDirectoryListBox.h"
#include "qt/window/QtSettingsWindow.h"
class QtApplicationSettingsScreen
: public QtSettingsWindow
{
Q_OBJECT
public:
QtApplicationSettingsScreen(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
virtual void setup() override;
void load();
protected:
virtual void populateForm(QFormLayout* layout) override;
private slots:
void handleCancelButtonPress();
void handleUpdateButtonPress();
void handleIncludePathHelpPress();
void handleFrameworkPathHelpPress();
private:
QPushButton* m_cancelButton;
QPushButton* m_updateButton;
QtDirectoryListBox* m_includePaths;
QtDirectoryListBox* m_frameworkPaths;
};
#endif //QT_APPLICATION_SETTINGS_SCREEN_H
+553
View File
@@ -0,0 +1,553 @@
#include "qt/window/QtMainWindow.h"
#include <QApplication>
#include <QFileDialog>
#include <QDockWidget>
#include <QMenuBar>
#include <QMessageBox>
#include <QSettings>
#include <QSysInfo>
#include "component/view/View.h"
#include "component/view/CompositeView.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageFind.h"
#include "utility/messaging/type/MessageInterruptTasks.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageRedo.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageSaveProject.h"
#include "utility/messaging/type/MessageSwitchColorScheme.h"
#include "utility/messaging/type/MessageUndo.h"
#include "utility/messaging/type/MessageWindowFocus.h"
#include "utility/messaging/type/MessageZoom.h"
#include "version.h"
std::string QtMainWindow::m_windowSettingsPath = "data/window_settings.ini";
QtViewToggle::QtViewToggle(View* view, QWidget *parent)
: QWidget(parent)
, m_view(view)
{
}
void QtViewToggle::toggledByAction()
{
dynamic_cast<QtMainWindow*>(parent())->toggleView(m_view, true);
}
void QtViewToggle::toggledByUI()
{
dynamic_cast<QtMainWindow*>(parent())->toggleView(m_view, false);
}
QtMainWindow::QtMainWindow()
{
setObjectName("QtMainWindow");
setCentralWidget(nullptr);
setDockNestingEnabled(true);
setWindowIcon(QIcon("./data/gui/icon/logo_1024_1024.png"));
setWindowFlags(Qt::Widget);
QApplication::setOverrideCursor(Qt::ArrowCursor);
m_recentProjectAction = new QAction*[ApplicationSettings::MaximalAmountOfRecentProjects];
setupProjectMenu();
setupEditMenu();
setupViewMenu();
setupHelpMenu();
setupShortcuts();
// Need to call loadLayout here for right DockWidget size on Linux
// Seconde call is in Application.cpp
loadLayout();
}
void QtMainWindow::init()
{
showStartScreen();
}
QtMainWindow::~QtMainWindow()
{
if (m_recentProjectAction)
{
delete [] m_recentProjectAction;
}
}
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());
addDockWidget(Qt::TopDockWidgetArea, dock);
QtViewToggle* toggle = new QtViewToggle(view, this);
connect(dock, SIGNAL(visibilityChanged(bool)), toggle, SLOT(toggledByUI()));
QAction* action = new QAction(tr((view->getName() + " Window").c_str()), this);
action->setCheckable(true);
connect(action, SIGNAL(triggered()), toggle, SLOT(toggledByAction()));
m_viewMenu->insertAction(m_viewSeparator, action);
DockWidget dockWidget;
dockWidget.widget = dock;
dockWidget.view = view;
dockWidget.action = action;
dockWidget.toggle = toggle;
m_dockWidgets.push_back(dockWidget);
}
void QtMainWindow::removeView(View* view)
{
for (size_t i = 0; i < m_dockWidgets.size(); i++)
{
if (m_dockWidgets[i].view == view)
{
removeDockWidget(m_dockWidgets[i].widget);
m_dockWidgets.erase(m_dockWidgets.begin() + i);
return;
}
}
}
void QtMainWindow::showView(View* view)
{
getDockWidgetForView(view)->widget->setHidden(false);
}
void QtMainWindow::hideView(View* view)
{
getDockWidgetForView(view)->widget->setHidden(true);
}
void QtMainWindow::loadLayout()
{
QSettings settings(m_windowSettingsPath.c_str(), QSettings::IniFormat);
settings.beginGroup("MainWindow");
resize(settings.value("size", QSize(600, 400)).toSize());
move(settings.value("position", QPoint(200, 200)).toPoint());
if (settings.value("maximized", false).toBool())
{
showMaximized();
}
settings.endGroup();
this->restoreState(settings.value("DOCK_LOCATIONS").toByteArray());
for (DockWidget dock : m_dockWidgets)
{
dock.action->setChecked(!dock.widget->isHidden());
}
}
void QtMainWindow::saveLayout()
{
QSettings settings(m_windowSettingsPath.c_str(), QSettings::IniFormat);
settings.beginGroup("MainWindow");
settings.setValue("maximized", isMaximized());
if (!isMaximized())
{
settings.setValue("size", size());
settings.setValue("position", pos());
}
settings.endGroup();
settings.setValue("DOCK_LOCATIONS", this->saveState());
}
bool QtMainWindow::event(QEvent* event)
{
if (event->type() == QEvent::WindowActivate)
{
MessageWindowFocus().dispatch();
}
return QMainWindow::event(event);
}
void QtMainWindow::pushWindow(QWidget* window)
{
if (m_windowStack.size())
{
m_windowStack.back()->hide();
}
window->show();
m_windowStack.push_back(window);
}
void QtMainWindow::popWindow()
{
if (m_windowStack.size())
{
m_windowStack.back()->hide();
m_windowStack.pop_back();
}
if (m_windowStack.size())
{
m_windowStack.back()->show();
}
}
void QtMainWindow::clearWindows()
{
if (m_windowStack.size())
{
m_windowStack.back()->hide();
}
m_windowStack.clear();
}
void QtMainWindow::about()
{
if (!m_aboutWindow)
{
m_aboutWindow = std::make_shared<QtAbout>(this);
m_aboutWindow->setup();
connect(m_aboutWindow.get(), SIGNAL(finished()), this, SLOT(popWindow()));
}
pushWindow(m_aboutWindow.get());
}
void QtMainWindow::openSettings()
{
if (!m_applicationSettingsScreen)
{
m_applicationSettingsScreen = std::make_shared<QtApplicationSettingsScreen>(this);
m_applicationSettingsScreen->setup();
connect(m_applicationSettingsScreen.get(), SIGNAL(finished()), this, SLOT(popWindow()));
connect(m_applicationSettingsScreen.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
}
m_applicationSettingsScreen->load();
pushWindow(m_applicationSettingsScreen.get());
}
void QtMainWindow::showLicenses()
{
if (!m_licenseWindow)
{
m_licenseWindow = std::make_shared<QtAboutLicense>(this);
m_licenseWindow->setup();
connect(m_licenseWindow.get(), SIGNAL(finished()), this, SLOT(popWindow()));
}
pushWindow(m_licenseWindow.get());
}
void QtMainWindow::showStartScreen()
{
if (!m_startScreen)
{
m_startScreen = std::make_shared<QtStartScreen>(this);
m_startScreen->setup();
connect(m_startScreen.get(), SIGNAL(finished()), this, SLOT(popWindow()));
connect(m_startScreen.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
connect(m_startScreen.get(), SIGNAL(openOpenProjectDialog()), this, SLOT(openProject()));
connect(m_startScreen.get(), SIGNAL(openNewProjectDialog()), this, SLOT(newProject()));
}
pushWindow(m_startScreen.get());
}
void QtMainWindow::newProject()
{
if (!m_newProjectDialog)
{
m_newProjectDialog = std::make_shared<QtProjectSetupScreen>(this);
m_newProjectDialog->setup();
connect(m_newProjectDialog.get(), SIGNAL(finished()), this, SLOT(clearWindows()));
connect(m_newProjectDialog.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
connect(m_newProjectDialog.get(), SIGNAL(showPreferences()), this, SLOT(openSettings()));
}
m_newProjectDialog->loadEmpty();
pushWindow(m_newProjectDialog.get());
}
void QtMainWindow::openProject(const QString &path)
{
QString fileName = path;
if (fileName.isNull())
{
fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", "Coati Project Files (*.coatiproject)");
}
if (!fileName.isEmpty())
{
MessageLoadProject(fileName.toStdString()).dispatch();
clearWindows();
}
}
void QtMainWindow::editProject()
{
newProject();
m_newProjectDialog->loadProjectSettings();
}
void QtMainWindow::find()
{
MessageFind().dispatch();
}
void QtMainWindow::closeWindow()
{
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
QWidget* activeWindow = app->activeWindow();
if (activeWindow)
{
activeWindow->close();
}
}
void QtMainWindow::refresh()
{
MessageRefresh().dispatch();
}
void QtMainWindow::forceRefresh()
{
MessageRefresh().refreshAll().dispatch();
}
void QtMainWindow::saveProject()
{
MessageSaveProject("").dispatch();
}
void QtMainWindow::saveAsProject()
{
QString filename = "";
filename = QFileDialog::getSaveFileName(this, "Save File as", "", "Coati Project Files(*.coatiproject)");
if(!filename.isEmpty())
{
MessageSaveProject(filename.toStdString()).dispatch();
}
}
void QtMainWindow::undo()
{
MessageUndo().dispatch();
}
void QtMainWindow::redo()
{
MessageRedo().dispatch();
}
void QtMainWindow::zoomIn()
{
MessageZoom(true).dispatch();
}
void QtMainWindow::zoomOut()
{
MessageZoom(false).dispatch();
}
void QtMainWindow::switchColorScheme()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "./data/color_schemes", "XML Files (*.xml)");
if (!fileName.isEmpty())
{
MessageSwitchColorScheme(fileName.toStdString()).dispatch();
}
}
void QtMainWindow::toggleView(View* view, bool fromMenu)
{
DockWidget* dock = getDockWidgetForView(view);
if (fromMenu)
{
dock->widget->setVisible(dock->action->isChecked());
}
else
{
dock->action->setChecked(dock->widget->isVisible());
}
}
void QtMainWindow::handleEscapeShortcut()
{
popWindow();
MessageInterruptTasks().dispatch();
}
void QtMainWindow::setupProjectMenu()
{
QMenu *menu = new QMenu(tr("&Project"), this);
menuBar()->addMenu(menu);
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->addSeparator();
menu->addAction(tr("&Save Project"), this, SLOT(saveProject()), QKeySequence::Save);
menu->addAction(tr("Save Project as..."), this, SLOT(saveAsProject()), QKeySequence::SaveAs);
menu->addSeparator();
QMenu *recentProjectMenu = new QMenu(tr("Recent Projects"));
menu->addMenu(recentProjectMenu);
for (int i = 0; i < ApplicationSettings::MaximalAmountOfRecentProjects; ++i)
{
m_recentProjectAction[i] = new QAction(this);
m_recentProjectAction[i]->setVisible(false);
connect(m_recentProjectAction[i], SIGNAL(triggered()),
this, SLOT(openRecentProject()));
recentProjectMenu->addAction(m_recentProjectAction[i]);
}
updateRecentProjectMenu();
menu->addMenu(recentProjectMenu);
menu->addSeparator();
menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit);
}
void QtMainWindow::openRecentProject()
{
QAction *action = qobject_cast<QAction *>(sender());
if (action)
{
openProject(action->data().toString());
}
}
void QtMainWindow::updateRecentProjectMenu()
{
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
for (size_t i = 0; i < ApplicationSettings::MaximalAmountOfRecentProjects; i++)
{
if(i < recentProjects.size())
{
FilePath project = recentProjects[i];
m_recentProjectAction[i]->setVisible(true);
m_recentProjectAction[i]->setText(FileSystem::fileName(project.str()).c_str());
m_recentProjectAction[i]->setData(project.str().c_str());
}
else
{
m_recentProjectAction[i]->setVisible(false);
}
}
}
void QtMainWindow::setWindowSettingsPath(const std::string& windowSettingsPath)
{
m_windowSettingsPath = windowSettingsPath;
}
void QtMainWindow::setupEditMenu()
{
QMenu *menu = new QMenu(tr("&Edit"), this);
menuBar()->addMenu(menu);
menu->addAction(tr("Undo"), this, SLOT(undo()), QKeySequence::Undo);
menu->addAction(tr("Redo"), this, SLOT(redo()), QKeySequence::Redo);
menu->addSeparator();
menu->addAction(tr("&Refresh"), this, SLOT(refresh()), QKeySequence::Refresh);
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5));
}
else
{
menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_R));
}
menu->addAction(tr("&Find"), this, SLOT(find()), QKeySequence::Find);
}
void QtMainWindow::setupViewMenu()
{
QMenu *menu = new QMenu(tr("&View"), this);
menuBar()->addMenu(menu);
m_viewSeparator = menu->addSeparator();
menu->addAction(tr("Larger font"), this, SLOT(zoomIn()), QKeySequence::ZoomIn);
menu->addAction(tr("Smaller font"), this, SLOT(zoomOut()), QKeySequence::ZoomOut);
menu->addAction(tr("Switch Color Scheme..."), this, SLOT(switchColorScheme()));
m_viewMenu = menu;
}
void QtMainWindow::setupHelpMenu()
{
QMenu *menu = new QMenu(tr("&Help"), this);
menuBar()->addMenu(menu);
menu->addAction(tr("&About"), this, SLOT(about()));
menu->addAction(tr("Licences"), this, SLOT(showLicenses()));
menu->addAction(tr("Preferences..."), this, SLOT(openSettings()));
}
void QtMainWindow::setupShortcuts()
{
m_escapeShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(m_escapeShortcut, SIGNAL(activated()), SLOT(handleEscapeShortcut()));
}
QtMainWindow::DockWidget* QtMainWindow::getDockWidgetForView(View* view)
{
for (DockWidget& dock : m_dockWidgets)
{
if (dock.view == view)
{
return &dock;
}
const CompositeView* compositeView = dynamic_cast<const CompositeView*>(dock.view);
if (compositeView)
{
for (const View* v : compositeView->getViews())
{
if (v == view)
{
return &dock;
}
}
}
}
LOG_ERROR("DockWidget was not found for view.");
return nullptr;
}
+132
View File
@@ -0,0 +1,132 @@
#ifndef QT_MAIN_WINDOW_H
#define QT_MAIN_WINDOW_H
#include <memory>
#include <utility>
#include <vector>
#include <QMainWindow>
#include <QShortcut>
#include "qt/window/QtApplicationSettingsScreen.h"
#include "qt/window/QtStartScreen.h"
#include "qt/window/QtProjectSetupScreen.h"
#include "qt/window/QtAboutLicense.h"
#include "qt/window/QtAbout.h"
class QDockWidget;
class View;
class QtViewToggle
: public QWidget
{
Q_OBJECT
public:
QtViewToggle(View* view, QWidget *parent = nullptr);
public slots:
void toggledByAction();
void toggledByUI();
private:
View* m_view;
};
class QtMainWindow: public QMainWindow
{
Q_OBJECT
public:
QtMainWindow();
~QtMainWindow();
void init();
void addView(View* view);
void removeView(View* view);
void showView(View* view);
void hideView(View* view);
void loadLayout();
void saveLayout();
protected:
bool event(QEvent* event);
public slots:
void pushWindow(QWidget* window);
void popWindow();
void clearWindows();
void about();
void openSettings();
void showLicenses();
void showStartScreen();
void newProject();
void openProject(const QString &path = QString());
void editProject();
void openRecentProject();
void find();
void closeWindow();
void refresh();
void forceRefresh();
void saveProject();
void saveAsProject();
void undo();
void redo();
void zoomIn();
void zoomOut();
void switchColorScheme();
void toggleView(View* view, bool fromMenu);
void handleEscapeShortcut();
void updateRecentProjectMenu();
static void setWindowSettingsPath(const std::string& windowSettingsPath);
private:
struct DockWidget
{
QDockWidget* widget;
View* view;
QAction* action;
QtViewToggle* toggle;
};
void setupEditMenu();
void setupProjectMenu();
void setupViewMenu();
void setupHelpMenu();
void setupShortcuts();
DockWidget* getDockWidgetForView(View* view);
std::vector<DockWidget> m_dockWidgets;
QMenu* m_viewMenu;
QAction* m_viewSeparator;
QAction** m_recentProjectAction;
std::shared_ptr<QtApplicationSettingsScreen> m_applicationSettingsScreen;
std::shared_ptr<QtStartScreen> m_startScreen;
std::shared_ptr<QtProjectSetupScreen> m_newProjectDialog;
std::shared_ptr<QtAboutLicense> m_licenseWindow;
std::shared_ptr<QtAbout> m_aboutWindow;
std::vector<QWidget*> m_windowStack;
QShortcut* m_escapeShortcut;
static std::string m_windowSettingsPath;
};
#endif // QT_MAIN_WINDOW_H
@@ -0,0 +1,247 @@
#include "qt/window/QtProjectSetupScreen.h"
#include <QComboBox>
#include <QFileDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QMessageBox>
#include <QSysInfo>
#include "utility/messaging/type/MessageLoadProject.h"
#include "settings/ProjectSettings.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 QtLineEdit(this);
m_data->setAttribute(Qt::WA_MacShowFocusRect, 0);
m_data->setObjectName("locationField");
m_button = new QPushButton("...");
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 Directory"), "");
if (!file.isEmpty())
{
m_data->setText(file);
}
}
QtProjectSetupScreen::QtProjectSetupScreen(QWidget *parent)
: QtSettingsWindow(parent)
, m_frameworkPaths(nullptr)
{
raise();
}
QSize QtProjectSetupScreen::sizeHint() const
{
return QSize(600,600);
}
void QtProjectSetupScreen::clear()
{
m_projectName->setText("");
m_projectFileLocation->setText("");
m_sourcePaths->clear();
m_includePaths->clear();
if (m_frameworkPaths)
{
m_frameworkPaths->clear();
}
}
void QtProjectSetupScreen::setup()
{
setupForm();
QPushButton* preferencesButton = new QPushButton("Preferences");
preferencesButton->setObjectName("windowButton");
connect(preferencesButton, SIGNAL(clicked()), this, SLOT(handlePreferencesButtonPress()));
m_buttonsLayout->insertWidget(2, preferencesButton);
m_buttonsLayout->insertStretch(3);
}
void QtProjectSetupScreen::loadEmpty()
{
updateTitle("NEW PROJECT");
updateDoneButton("Create");
}
void QtProjectSetupScreen::loadProjectSettings()
{
updateTitle("EDIT PROJECT");
updateDoneButton("Save");
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());
if (m_frameworkPaths)
{
m_frameworkPaths->setList(projSettings->getFrameworkSearchPaths());
}
}
void QtProjectSetupScreen::populateForm(QFormLayout* layout)
{
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);
QPushButton* helpButton;
QWidget* sourcePathsWidget = createLabelWithHelpButton("Source Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleSourcePathHelpPress()));
m_sourcePaths = new QtDirectoryListBox(this);
m_sourcePaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(sourcePathsWidget, m_sourcePaths);
QWidget* includePathsWidget = createLabelWithHelpButton("Header\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleIncludePathHelpPress()));
m_includePaths = new QtDirectoryListBox(this);
m_includePaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(includePathsWidget, m_includePaths);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
QWidget* frameworkPathsWidget = createLabelWithHelpButton("Framework\nSearch Paths", &helpButton);
connect(helpButton, SIGNAL(clicked()), this, SLOT(handleFrameworkPathHelpPress()));
m_frameworkPaths = new QtDirectoryListBox(this);
m_frameworkPaths->setMinimumWidth(minimumWidthForSecondCol);
layout->addRow(frameworkPathsWidget, m_frameworkPaths);
}
}
void QtProjectSetupScreen::handleCancelButtonPress()
{
emit canceled();
}
void QtProjectSetupScreen::handleUpdateButtonPress()
{
if (m_projectName->text().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please enter a project name.");
msgBox.exec();
return;
}
if (m_projectFileLocation->getText().isEmpty())
{
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() + ".coatiproject";
projSettings->save(projectFile);
MessageLoadProject(projectFile).dispatch();
clear();
emit finished();
}
void QtProjectSetupScreen::handleSourcePathHelpPress()
{
showHelpMessage(
"Source Paths define the files and directories that will be analysed by Coati. Usually these are the source "
"files of your project or a subset of them."
);
}
void QtProjectSetupScreen::handleIncludePathHelpPress()
{
showHelpMessage(
"Header Search Paths define where additional headers, that your project depends on, are found. Usually they are "
"header files of frameworks or libraries that your project uses. These files won't be analysed, but Coati needs "
"them for correct analysis.\n\n"
"Please note that you can define Header Search Paths for all your projects in Coati's preferences."
);
}
void QtProjectSetupScreen::handleFrameworkPathHelpPress()
{
showHelpMessage(
"Framework Search Paths define where MacOS framework containers, that your project depends on, are found.\n\n"
"Please note that you can define Framework Search Paths for all your projects in Coati's preferences."
);
}
void QtProjectSetupScreen::handlePreferencesButtonPress()
{
emit showPreferences();
}
@@ -0,0 +1,77 @@
#ifndef QT_PROJECT_SETUP_SCREEN_H
#define QT_PROJECT_SETUP_SCREEN_H
#include <QPushButton>
#include <QWidget>
#include "utility/file/FilePath.h"
#include "qt/element/QtDirectoryListBox.h"
#include "qt/element/QtLineEdit.h"
#include "qt/window/QtSettingsWindow.h"
class QtTextLine
: public QWidget
{
Q_OBJECT
public:
QtTextLine(QWidget *parent);
QString getText();
void setText(QString text);
private slots:
void handleButtonPress();
private:
QPushButton* m_button;
QtLineEdit* m_data;
};
class QtProjectSetupScreen
: public QtSettingsWindow
{
Q_OBJECT
public:
QtProjectSetupScreen(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
void clear();
virtual void setup() override;
void loadEmpty();
void loadProjectSettings();
void projectSetupScreen();
signals:
void showPreferences();
protected:
virtual void populateForm(QFormLayout* layout) override;
private slots:
void handleCancelButtonPress();
void handleUpdateButtonPress();
void handleSourcePathHelpPress();
void handleIncludePathHelpPress();
void handleFrameworkPathHelpPress();
void handlePreferencesButtonPress();
private:
QLineEdit* m_projectName;
QtTextLine* m_projectFileLocation;
QtDirectoryListBox* m_includePaths;
QtDirectoryListBox* m_sourcePaths;
QtDirectoryListBox* m_frameworkPaths;
QPushButton* m_preferencesButton;
};
#endif //QT_PROJECT_SETUP_SCREEN_H
+229
View File
@@ -0,0 +1,229 @@
#include "qt/window/QtSettingsWindow.h"
#include <QFormLayout>
#include <QGraphicsDropShadowEffect>
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QScrollArea>
#include <QSysInfo>
#include "qt/utility/QtDeviceScaledPixmap.h"
#include "qt/utility/utilityQt.h"
#include "utility/messaging/type/MessageInterruptTasks.h"
QtSettingsWindow::QtSettingsWindow(QWidget *parent, int displacement)
: QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint)
, m_title(nullptr)
, m_cancelButton(nullptr)
, m_doneButton(nullptr)
, 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->resize(windowSize);
std::string frameStyle =
"#SettingWindow {"
"font-size: 17pt; "
"border: 1px solid lightgray;"
"border-radius: 15px; "
"background: white; "
"}";
m_window->setStyleSheet(frameStyle.c_str());
m_window->setObjectName("SettingWindow");
// 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();
}
QSize QtSettingsWindow::sizeHint() const
{
return QSize(500, 500);
}
void QtSettingsWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape)
{
emit canceled();
}
}
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;
}
}
void QtSettingsWindow::setupForm()
{
QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo_blurry.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/setting_window/window.css").c_str());
QVBoxLayout* windowLayout = new QVBoxLayout();
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("formArea");
scrollArea->setFrameShadow(QFrame::Plain);
scrollArea->setWidgetResizable(true);
QWidget* form = new QWidget();
form->setObjectName("form");
scrollArea->setWidget(form);
QFormLayout* layout = new QFormLayout();
layout->setContentsMargins(10, 10, 10, 10);
layout->setHorizontalSpacing(20);
populateForm(layout);
form->setLayout(layout);
m_cancelButton = new QPushButton("Cancel");
m_cancelButton->setObjectName("windowButton");
m_doneButton = new QPushButton("Done");
m_doneButton->setObjectName("windowButton");
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(handleCancelButtonPress()));
connect(m_doneButton, SIGNAL(clicked()), this, SLOT(handleUpdateButtonPress()));
QHBoxLayout* buttons = new QHBoxLayout();
buttons->addWidget(m_cancelButton);
buttons->addStretch();
buttons->addWidget(m_doneButton);
m_buttonsLayout = buttons;
windowLayout->addWidget(scrollArea);
windowLayout->addSpacing(20);
windowLayout->addLayout(buttons);
m_window->setLayout(windowLayout);
resize(QSize(600, 620));
scrollArea->raise();
}
void QtSettingsWindow::populateForm(QFormLayout* layout)
{
}
void QtSettingsWindow::updateTitle(QString title)
{
if (m_title)
{
m_title->setText(title);
}
}
void QtSettingsWindow::updateDoneButton(QString text)
{
if (m_doneButton)
{
m_doneButton->setText(text);
}
}
void QtSettingsWindow::hideCancelButton(bool hidden)
{
if(m_cancelButton)
{
m_cancelButton->setVisible(!hidden);
}
}
QWidget* QtSettingsWindow::createLabelWithHelpButton(QString name, QPushButton** helpButton)
{
QWidget* widget = new QWidget();
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 5, 0, 5);
layout->setSpacing(5);
QLabel* label = new QLabel(name);
label->setAlignment(Qt::AlignRight);
layout->addWidget(label);
QPushButton* button = new QPushButton("?");
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
button->setObjectName("help");
layout->addWidget(button, 0, Qt::AlignRight);
layout->addStretch();
widget->setLayout(layout);
*helpButton = button;
return widget;
}
void QtSettingsWindow::showHelpMessage(const QString& msg)
{
QMessageBox msgBox;
msgBox.setText("Help");
msgBox.setInformativeText(msg);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
}
+61
View File
@@ -0,0 +1,61 @@
#ifndef QT_SETTINGS_WINDOW_H
#define QT_SETTINGS_WINDOW_H
#include <QHBoxLayout>
#include <QResizeEvent>
#include <QWidget>
class QFormLayout;
class QLabel;
class QPushButton;
class QtSettingsWindow
: public QWidget
{
Q_OBJECT
public:
QtSettingsWindow(QWidget* parent = 0, int displacement = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
virtual void setup() = 0;
signals:
void finished();
void canceled();
protected:
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;
void setupForm();
virtual void populateForm(QFormLayout* layout);
void updateTitle(QString title);
void updateDoneButton(QString text);
void hideCancelButton(bool hidden);
QWidget* createLabelWithHelpButton(QString name, QPushButton** helpButton);
void showHelpMessage(const QString& msg);
QWidget* m_window;
QLabel* m_title;
QPushButton* m_cancelButton;
QPushButton* m_doneButton;
QHBoxLayout* m_buttonsLayout;
private:
int m_displacment;
QPoint m_dragPosition;
bool m_mousePressedInWindow;
};
#endif //QT_SETTINGS_WINDOW_H
+102
View File
@@ -0,0 +1,102 @@
#include "qt/window/QtSplashScreen.h"
#include <QApplication>
#include <QThread>
#include <QTimer>
#include "qt/utility/QtDeviceScaledPixmap.h"
namespace
{
class InitThread : public QThread
{
public:
void run(void)
{
// Mininmum time the SplashScreen gets displayed.
QThread::msleep(5000);
}
};
}
QtSplashScreen::QtSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
: QSplashScreen(pixmap, f)
, m_state(0)
{
QtDeviceScaledPixmap foreground("data/gui/splash_white.png");
foreground.scaleToHeight(pixmap.size().height() * 0.8);
m_foreground = foreground.pixmap();
QtDeviceScaledPixmap background("data/gui/splash_blue.png");
background.scaleToHeight(pixmap.size().height() * 0.9);
m_background = background.pixmap();
}
QtSplashScreen::~QtSplashScreen()
{
}
void QtSplashScreen::exec(QApplication& app)
{
m_state = 0;
QTimer* timer = new QTimer(this);
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
timer->start(150);
app.processEvents();
show();
repaint();
app.processEvents();
// Eventloop for the SplashScreen
// QEventLoop loop;
// InitThread* initThread = new InitThread();
// QObject::connect(initThread, SIGNAL(finished()), &loop, SLOT(quit()));
// initThread->start();
// loop.exec();
}
void QtSplashScreen::setMessage(const QString &str)
{
m_string = str;
repaint();
}
void QtSplashScreen::setVersion(const QString &str)
{
m_version = str;
repaint();
}
void QtSplashScreen::animate()
{
m_state = (m_state + 2) % 120;
repaint();
}
void QtSplashScreen::drawContents(QPainter *painter)
{
painter->save();
painter->translate(rect().width() / 2, rect().height() / 2);
painter->rotate(m_state * 3);
painter->drawPixmap(-rect().width() * 0.9 / 2, -rect().height() * 0.9 / 2, m_background);
painter->restore();
painter->drawPixmap(rect().width() * 0.1, rect().height() * 0.1, m_foreground);
QRect r = rect();
r.setRect(r.x() + 5, r.height() - 20, r.width() - 10, 20);
painter->drawText(r, Qt::AlignRight, QString("Coati v").append(m_version));
// Draw message at given position, limited to 43 chars
// If message is too long, string is truncated
if (m_string.length() > 40)
{
m_string.truncate(39);
m_string += "...";
}
painter->drawText(r, Qt::AlignLeft, m_string);
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef QTSPLASHSCREEN_H
#define QTSPLASHSCREEN_H
#include <QSplashScreen>
#include <QPainter>
#include <QWidget>
class QApplication;
class QPixmap;
class QtSplashScreen
: public QSplashScreen
{
Q_OBJECT
public:
QtSplashScreen(const QPixmap& pixmap, Qt::WindowFlags f = 0);
virtual ~QtSplashScreen();
void exec(QApplication& app);
void setMessage(const QString& str);
void setVersion(const QString& str);
public slots:
void animate();
private:
void drawContents(QPainter* painter);
int m_state;
QString m_string;
QString m_version;
QPixmap m_background;
QPixmap m_foreground;
};
#endif //QTSPLASHSCREEN_H
+99
View File
@@ -0,0 +1,99 @@
#include "qt/window/QtStartScreen.h"
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#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()
{
MessageLoadProject(m_projectFile).dispatch();
};
QtStartScreen::QtStartScreen(QWidget *parent)
: QtSettingsWindow(parent, 68)
{
this->raise();
}
void QtStartScreen::setup()
{
setStyleSheet(utility::getStyleSheet("data/gui/startscreen/startscreen.css").c_str());
QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo.png");
coati_logo.scaleToWidth(200);
QLabel* coatiLogoLabel = new QLabel(this);
coatiLogoLabel->setPixmap(coati_logo.pixmap());
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, 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, 540, 140, 30);
m_openProjectButton->setObjectName("projectButton");
connect(m_openProjectButton, SIGNAL(clicked()), this, SLOT(handleOpenProjectButton()));
QLabel* recentProjectsLabel = new QLabel("Recent Projects: ", this);
recentProjectsLabel->setGeometry(300, 234, 300, 50);
recentProjectsLabel->setObjectName("recentLabel");
int position = 290;
QIcon cpp_icon("data/gui/startscreen/icon_cpp.png");
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
for (size_t i = 0; i < recentProjects.size() && i < ApplicationSettings::MaximalAmountOfRecentProjects; i++)
{
FilePath project = recentProjects[i];
QtRecentProjectButton* button = new QtRecentProjectButton(project.str().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()));
connect(button, SIGNAL(clicked()), this, SLOT(handleRecentButton()));
position += 40;
}
resize(600, 600);
}
QSize QtStartScreen::sizeHint() const
{
return QSize(500, 500);
}
void QtStartScreen::handleNewProjectButton()
{
emit openNewProjectDialog();
}
void QtStartScreen::handleOpenProjectButton()
{
emit openOpenProjectDialog();
}
void QtStartScreen::handleRecentButton()
{
emit finished();
}
+49
View File
@@ -0,0 +1,49 @@
#ifndef QT_START_SCREEN_H
#define QT_START_SCREEN_H
#include <QPushButton>
#include "qt/window/QtSettingsWindow.h"
class QtRecentProjectButton
: public QPushButton
{
Q_OBJECT
public:
QtRecentProjectButton(const QString& text, QWidget* parent);
public slots:
void handleButtonClick();
private:
std::string m_projectFile;
};
class QtStartScreen
: public QtSettingsWindow
{
Q_OBJECT
public:
QtStartScreen(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
virtual void setup() override;
signals:
void openOpenProjectDialog();
void openNewProjectDialog();
private slots:
void handleNewProjectButton();
void handleOpenProjectButton();
void handleRecentButton();
private:
QPushButton* m_openProjectButton;
QPushButton* m_newProjectButton;
std::vector<QPushButton*> m_recentProjects;
};
#endif // QT_START_SCREEN_H