ui: Recent projects in menu
add a recent projects menu in the project menu
This commit is contained in:
@@ -24,3 +24,4 @@
|
|||||||
/ide_plugins/vs/vs2012/CoatiPlugin/CoatiPlugin/obj
|
/ide_plugins/vs/vs2012/CoatiPlugin/CoatiPlugin/obj
|
||||||
|
|
||||||
*.sqlite
|
*.sqlite
|
||||||
|
*.swp
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "component/view/CompositeView.h"
|
#include "component/view/CompositeView.h"
|
||||||
#include "qt/view/QtViewWidgetWrapper.h"
|
#include "qt/view/QtViewWidgetWrapper.h"
|
||||||
#include "settings/ApplicationSettings.h"
|
#include "settings/ApplicationSettings.h"
|
||||||
|
#include "utility/file/FileSystem.h"
|
||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
#include "utility/messaging/type/MessageFind.h"
|
#include "utility/messaging/type/MessageFind.h"
|
||||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||||
@@ -42,7 +43,6 @@ void QtViewToggle::toggledByUI()
|
|||||||
dynamic_cast<QtMainWindow*>(parent())->toggleView(m_view, false);
|
dynamic_cast<QtMainWindow*>(parent())->toggleView(m_view, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QtMainWindow::QtMainWindow()
|
QtMainWindow::QtMainWindow()
|
||||||
: m_startScreenWasVisible(false)
|
: m_startScreenWasVisible(false)
|
||||||
{
|
{
|
||||||
@@ -55,6 +55,8 @@ QtMainWindow::QtMainWindow()
|
|||||||
|
|
||||||
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
QApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||||
|
|
||||||
|
m_recentProjectAction = new QAction*[ApplicationSettings::MaximalAmountOfRecentProjects];
|
||||||
|
|
||||||
setupProjectMenu();
|
setupProjectMenu();
|
||||||
setupEditMenu();
|
setupEditMenu();
|
||||||
setupViewMenu();
|
setupViewMenu();
|
||||||
@@ -188,8 +190,16 @@ bool QtMainWindow::event(QEvent* event)
|
|||||||
void QtMainWindow::about()
|
void QtMainWindow::about()
|
||||||
{
|
{
|
||||||
hideScreens();
|
hideScreens();
|
||||||
m_aboutWindow = std::make_shared<QtAbout>(this);
|
|
||||||
m_aboutWindow->setup();
|
if (!m_aboutWindow)
|
||||||
|
{
|
||||||
|
m_aboutWindow = std::make_shared<QtAbout>(this);
|
||||||
|
m_aboutWindow->setup();
|
||||||
|
|
||||||
|
connect(m_aboutWindow.get(), SIGNAL(finished()), this, SLOT(closeScreens()));
|
||||||
|
connect(m_aboutWindow.get(), SIGNAL(canceled()), this, SLOT(restoreScreens()));
|
||||||
|
}
|
||||||
|
|
||||||
m_aboutWindow->show();
|
m_aboutWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,10 +431,62 @@ void QtMainWindow::setupProjectMenu()
|
|||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
|
QMenu *recentProjectMenu = new QMenu(tr("Recent Project"));
|
||||||
|
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("&Close Window"), this, SLOT(closeWindow()), QKeySequence::Close);
|
menu->addAction(tr("&Close Window"), this, SLOT(closeWindow()), QKeySequence::Close);
|
||||||
menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit);
|
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()-1)
|
||||||
|
{
|
||||||
|
FilePath project = recentProjects[i];
|
||||||
|
m_recentProjectAction[i]->setVisible(true);
|
||||||
|
if (project.exists())
|
||||||
|
{
|
||||||
|
m_recentProjectAction[i]->setText(FileSystem::fileName(project.str()).c_str());
|
||||||
|
m_recentProjectAction[i]->setData(project.str().c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_recentProjectAction[i]->setDisabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_recentProjectAction[i]->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QtMainWindow::showLicenses()
|
void QtMainWindow::showLicenses()
|
||||||
{
|
{
|
||||||
hideScreens();
|
hideScreens();
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public slots:
|
|||||||
void newProject();
|
void newProject();
|
||||||
void openProject(const QString &path = QString());
|
void openProject(const QString &path = QString());
|
||||||
void editProject();
|
void editProject();
|
||||||
|
void openRecentProject();
|
||||||
|
|
||||||
void find();
|
void find();
|
||||||
void closeWindow();
|
void closeWindow();
|
||||||
@@ -96,8 +97,10 @@ private:
|
|||||||
QtViewToggle* toggle;
|
QtViewToggle* toggle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void setupEditMenu();
|
void setupEditMenu();
|
||||||
void setupProjectMenu();
|
void setupProjectMenu();
|
||||||
|
void updateRecentProjectMenu();
|
||||||
void setupViewMenu();
|
void setupViewMenu();
|
||||||
void setupHelpMenu();
|
void setupHelpMenu();
|
||||||
|
|
||||||
@@ -108,6 +111,7 @@ private:
|
|||||||
std::vector<DockWidget> m_dockWidgets;
|
std::vector<DockWidget> m_dockWidgets;
|
||||||
QMenu* m_viewMenu;
|
QMenu* m_viewMenu;
|
||||||
QAction* m_viewSeparator;
|
QAction* m_viewSeparator;
|
||||||
|
QAction** m_recentProjectAction;
|
||||||
|
|
||||||
std::shared_ptr<QtApplicationSettingsScreen> m_applicationSettingsScreen;
|
std::shared_ptr<QtApplicationSettingsScreen> m_applicationSettingsScreen;
|
||||||
std::shared_ptr<QtStartScreen> m_startScreen;
|
std::shared_ptr<QtStartScreen> m_startScreen;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ void QtStartScreen::setup()
|
|||||||
int position = 290;
|
int position = 290;
|
||||||
QIcon cpp_icon("data/gui/startscreen/icon_cpp.png");
|
QIcon cpp_icon("data/gui/startscreen/icon_cpp.png");
|
||||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||||
for (size_t i = 0; i < recentProjects.size() && i < 7; i++)
|
for (size_t i = 0; i < recentProjects.size() && i < ApplicationSettings::MaximalAmountOfRecentProjects; i++)
|
||||||
{
|
{
|
||||||
FilePath project = recentProjects[i];
|
FilePath project = recentProjects[i];
|
||||||
if (project.exists())
|
if (project.exists())
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ public:
|
|||||||
|
|
||||||
std::string getStartupProjectFilePath() const;
|
std::string getStartupProjectFilePath() const;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MaximalAmountOfRecentProjects = 7
|
||||||
|
};
|
||||||
|
|
||||||
// source
|
// source
|
||||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||||
|
|||||||
Reference in New Issue
Block a user