tycho: use inheritance instead of QSharedPointers
parent
8889bcf1a4
commit
5e09c1dae8
|
@ -2,14 +2,11 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
#include "../ui/ui_mapprops.h"
|
||||
|
||||
class ProjectModel;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MapProps;
|
||||
}
|
||||
|
||||
class MapProps : public QDialog
|
||||
class MapProps : public QDialog, private Ui::MapProps
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -20,7 +17,6 @@ public:
|
|||
|
||||
private:
|
||||
QSharedPointer<ProjectModel> proj;
|
||||
QSharedPointer<Ui::MapProps> ui;
|
||||
};
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -3,15 +3,11 @@
|
|||
#include <QMainWindow>
|
||||
#include <vector>
|
||||
|
||||
#include "../ui/ui_menu.h"
|
||||
|
||||
class ProjectView;
|
||||
class QMdiSubWindow;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class Menu;
|
||||
}
|
||||
|
||||
class Menu : public QMainWindow
|
||||
class Menu : public QMainWindow, private Ui::Menu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -34,8 +30,6 @@ private:
|
|||
ProjectView *activeProject() const;
|
||||
QMdiSubWindow *activeSubWindow() const;
|
||||
void addProject(ProjectView *view);
|
||||
|
||||
QSharedPointer<Ui::Menu> ui;
|
||||
};
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "bindings.h"
|
||||
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ProjectView;
|
||||
}
|
||||
#include "bindings.h"
|
||||
#include "../ui/ui_projectview.h"
|
||||
|
||||
class ProjectModel : public QObject
|
||||
{
|
||||
|
@ -27,7 +23,7 @@ private:
|
|||
Project data;
|
||||
};
|
||||
|
||||
class ProjectView : public QMdiSubWindow
|
||||
class ProjectView : public QMdiSubWindow, private Ui::ProjectView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -41,7 +37,6 @@ protected:
|
|||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
QSharedPointer<Ui::ProjectView> ui;
|
||||
QSharedPointer<ProjectModel> proj;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
#include "tycho.h"
|
||||
#include "mapprops.h"
|
||||
#include "../ui/ui_mapprops.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
MapProps::MapProps(QSharedPointer<ProjectModel> _proj, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::MapProps),
|
||||
proj(_proj)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
setModal(true);
|
||||
|
||||
auto bbox = new QDialogButtonBox(this);
|
||||
bbox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||
ui->verticalLayout->addWidget(bbox);
|
||||
verticalLayout->addWidget(bbox);
|
||||
|
||||
connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "mapprops.h"
|
||||
#include "menu.h"
|
||||
#include "project.h"
|
||||
#include "../ui/ui_menu.h"
|
||||
#include "../ui/ui_about.h"
|
||||
#include "../ui/ui_license.h"
|
||||
|
||||
|
@ -12,17 +11,16 @@
|
|||
#include <iostream>
|
||||
|
||||
Menu::Menu(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Menu)
|
||||
QMainWindow(parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
ui->actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
||||
ui->actionClose->setShortcut(QKeySequence(QKeySequence::Close));
|
||||
ui->actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P")));
|
||||
ui->actionNew->setShortcut(QKeySequence(QKeySequence::New));
|
||||
ui->actionOpen->setShortcut(QKeySequence(QKeySequence::Open));
|
||||
ui->actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
|
||||
actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
||||
actionClose->setShortcut(QKeySequence(QKeySequence::Close));
|
||||
actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P")));
|
||||
actionNew->setShortcut(QKeySequence(QKeySequence::New));
|
||||
actionOpen->setShortcut(QKeySequence(QKeySequence::Open));
|
||||
actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
|
||||
|
||||
dbgPrintFunc();
|
||||
}
|
||||
|
@ -111,15 +109,15 @@ void Menu::updateActions()
|
|||
auto view = activeProject();
|
||||
bool active = view != nullptr;
|
||||
|
||||
ui->actionClose->setEnabled(active);
|
||||
ui->actionMapProps->setEnabled(active);
|
||||
actionClose->setEnabled(active);
|
||||
actionMapProps->setEnabled(active);
|
||||
|
||||
dbgPrintFunc();
|
||||
}
|
||||
|
||||
void Menu::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
for(auto *win : ui->mdiArea->subWindowList()) {
|
||||
for(auto *win : mdiArea->subWindowList()) {
|
||||
if(!win->close()) {
|
||||
event->ignore();
|
||||
return;
|
||||
|
@ -136,12 +134,13 @@ ProjectView *Menu::activeProject() const
|
|||
|
||||
QMdiSubWindow *Menu::activeSubWindow() const
|
||||
{
|
||||
return ui->mdiArea->activeSubWindow();
|
||||
return mdiArea->activeSubWindow();
|
||||
}
|
||||
|
||||
void Menu::addProject(ProjectView *view)
|
||||
{
|
||||
auto win = ui->mdiArea->addSubWindow(view);
|
||||
auto win = mdiArea->addSubWindow(view);
|
||||
|
||||
win->showMaximized();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
#include "tycho.h"
|
||||
#include "project.h"
|
||||
#include "../ui/ui_projectview.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QMessageBox>
|
||||
|
||||
ProjectView::ProjectView(QWidget *parent) :
|
||||
QMdiSubWindow(parent),
|
||||
ui(new Ui::ProjectView),
|
||||
proj(new ProjectModel)
|
||||
{
|
||||
auto widget = new QWidget(this);
|
||||
|
||||
ui->setupUi(widget);
|
||||
setupUi(widget);
|
||||
|
||||
setWidget(widget);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
Loading…
Reference in New Issue