Skip to content
Snippets Groups Projects
Commit 1ef0795b authored by Baton Théau's avatar Baton Théau
Browse files

Merge branch 'dev' into vikii

parents 9ecbbb61 2c549eec
No related branches found
No related tags found
1 merge request!1Dev
Showing
with 671 additions and 18 deletions
...@@ -12,22 +12,34 @@ SOURCES += \ ...@@ -12,22 +12,34 @@ SOURCES += \
colorpickerwidget.cpp \ colorpickerwidget.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
tools/editable.cpp \
tools/hand.cpp \
tools/selectionnable.cpp \
tools/tool.cpp \ tools/tool.cpp \
ui/files/treefileselector.cpp \ ui/files/treefileselector.cpp \
ui/menu/displaymenulambda.cpp \
ui/menu/filemenulambda.cpp \ ui/menu/filemenulambda.cpp \
ui/menu/menubarmanager.cpp \ ui/menu/menubarmanager.cpp \
ui/toolbox/toolRegister.cpp \ ui/toolbox/toolRegister.cpp \
ui/view/imagearea.cpp \
ui/view/selection.cpp \
ui/view/viewmanager.cpp ui/view/viewmanager.cpp
HEADERS += \ HEADERS += \
colorpickerwidget.h \ colorpickerwidget.h \
mainwindow.h \ mainwindow.h \
tools/editable.h \
tools/hand.h \
tools/selectionnable.h \
tools/tool.h \ tools/tool.h \
ui/files/fileselector.h \ ui/files/fileselector.h \
ui/files/treefileselector.h \ ui/files/treefileselector.h \
ui/menu/displaymenulambda.h \
ui/menu/filemenulambda.h \ ui/menu/filemenulambda.h \
ui/menu/menubarmanager.h \ ui/menu/menubarmanager.h \
ui/toolbox/toolRegister.h \ ui/toolbox/toolRegister.h \
ui/view/imagearea.h \
ui/view/selection.h \
ui/view/viewmanager.h ui/view/viewmanager.h
FORMS += \ FORMS += \
......
...@@ -14,7 +14,7 @@ QString getStyleSheet(const QString & path) { ...@@ -14,7 +14,7 @@ QString getStyleSheet(const QString & path) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
QApplication application(argc, argv); QApplication application(argc, argv);
//application.setStyleSheet(getStyleSheet(":/stylesheet/ressource/stylesheet/QTDark.stylesheet")); application.setStyleSheet(getStyleSheet(":/stylesheet/ressource/stylesheet/QTDark.css"));
MainWindow window; MainWindow window;
window.show(); window.show();
......
...@@ -11,8 +11,12 @@ ...@@ -11,8 +11,12 @@
#include <ui/menu/filemenulambda.h> #include <ui/menu/filemenulambda.h>
#include <ui/menu/displaymenulambda.h>
#include <ui/files/treefileselector.h> #include <ui/files/treefileselector.h>
#include <tools/hand.h>
MainWindow::MainWindow(QWidget * parent) MainWindow::MainWindow(QWidget * parent)
: QMainWindow(parent), _toolRegister(), _fileselectorManager(nullptr), _viewManager(nullptr) { : QMainWindow(parent), _toolRegister(), _fileselectorManager(nullptr), _viewManager(nullptr) {
...@@ -21,13 +25,14 @@ MainWindow::MainWindow(QWidget * parent) ...@@ -21,13 +25,14 @@ MainWindow::MainWindow(QWidget * parent)
this->setAcceptDrops(true); this->setAcceptDrops(true);
this->_imageTabs->clear(); this->_imageTabs->clear();
this->_toolRegister.setToolbox(this->_toolbox); qDebug() << "Mark_1";
this->_toolRegister.update();
this->_fileselectorManager = new ui::TreeFileSelector(this->_filesSelector, this->_filesSelected, this); this->_fileselectorManager = new ui::TreeFileSelector(this->_filesSelector, this->_filesSelected, this);
QObject::connect(this->_remove_selectable_element, SIGNAL(released()), this->_fileselectorManager, SLOT(removeSelectedItem())); QObject::connect(this->_remove_selectable_element, SIGNAL(released()), this->_fileselectorManager, SLOT(removeSelectedItem()));
QObject::connect(this->_add_selectable_element, SIGNAL(released()), this->_fileselectorManager, SLOT(pushItem())); QObject::connect(this->_add_selectable_element, SIGNAL(released()), this->_fileselectorManager, SLOT(pushItem()));
<<<<<<< HEAD
ColorWindow = findChild<QPushButton*>("ColorWindow"); ColorWindow = findChild<QPushButton*>("ColorWindow");
// Connect the button's clicked signal to the openColorPicker slot // Connect the button's clicked signal to the openColorPicker slot
...@@ -37,11 +42,28 @@ MainWindow::MainWindow(QWidget * parent) ...@@ -37,11 +42,28 @@ MainWindow::MainWindow(QWidget * parent)
ctrlCAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C)); // Change the shortcut ctrlCAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C)); // Change the shortcut
connect(ctrlCAction, &QAction::triggered, this, &MainWindow::handleCtrlCKey); connect(ctrlCAction, &QAction::triggered, this, &MainWindow::handleCtrlCKey);
addAction(ctrlCAction); addAction(ctrlCAction);
=======
qDebug() << "Mark_2";
>>>>>>> dev
this->_viewManager = new ui::ViewManager(this->_fileselectorManager, this->_imageTabs); this->_viewManager = new ui::ViewManager(this->_fileselectorManager, this->_imageTabs);
this->_menubarManager.insert(this->_menuFile, QSharedPointer<ui::MenuLambda>(new ui::FilemenuLambda(this->_fileselectorManager))); qDebug() << "Mark_3";
this->_toolRegister.setToolbox(this->_toolbox);
this->_toolRegister.setViewManager(this->_viewManager);
this->_toolRegister.push_back(QSharedPointer<tool::Tool>(new tool::Hand()));
this->_toolRegister.update();
qDebug() << "Mark_4";
this->_menubarManager.insert(this->_menuFile, QSharedPointer<ui::MenuLambda>(new ui::FilemenuLambda(this->_fileselectorManager, this->_viewManager)));
this->_menubarManager.insert(this->_menuAffichage, QSharedPointer<ui::MenuLambda>(new ui::DisplayMenuLambda(this->_viewManager)));
this->_menubarManager.update(); this->_menubarManager.update();
qDebug() << "Mark_5";
} }
void MainWindow::dragEnterEvent(QDragEnterEvent *e) { void MainWindow::dragEnterEvent(QDragEnterEvent *e) {
......
...@@ -416,7 +416,5 @@ ...@@ -416,7 +416,5 @@
<file>ressource/image/oxygen/icons/16x16/zoom-select.png</file> <file>ressource/image/oxygen/icons/16x16/zoom-select.png</file>
<file>ressource/image/oxygen/icons/16x16/align-none.png</file> <file>ressource/image/oxygen/icons/16x16/align-none.png</file>
</qresource> </qresource>
<qresource prefix="/stylesheet"> <qresource prefix="/stylesheet"/>
<file>ressource/stylesheet/QTDark.stylesheet</file>
</qresource>
</RCC> </RCC>
/*
Copyright 2013 Emanuel Claesson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
COLOR_DARK = #191919
COLOR_MEDIUM = #353535
COLOR_MEDLIGHT = #5A5A5A
COLOR_LIGHT = #DDDDDD
COLOR_ACCENT = #3D7848
*/
* { * {
background: #191919; background: #191919;
color: #DDDDDD; color: #DDDDDD;
border: 1px solid #5A5A5A; border: 1px solid #5A5A5A;
} }
QWidget::item:selected { /* menu */
background: #3D7848; QMenuBar {
background-color: #002470;
color: white;
} }
QCheckBox, QRadioButton { /* menu items */
border: none; QMenuBar::item {
padding: 2px 20px 2px 20px;
border: 1px solid transparent;
} }
QRadioButton::indicator, QCheckBox::indicator { QMenuBar::item:selected {
width: 13px; border-color: rgb(48, 83, 136);
height: 13px; background: #3859a1;
} }
QRadioButton::indicator::unchecked, QCheckBox::indicator::unchecked { QMenuBar::item:pressed {
border: 1px solid #5A5A5A; background: #2f477a;
background: none;
} }
QRadioButton::indicator:unchecked:hover, QCheckBox::indicator:unchecked:hover { /* boxes */
border: 1px solid #DDDDDD; #_filesSelector {
border-bottom-right-radius: 10px;
margin-bottom: 5px;
} }
QRadioButton::indicator::checked, QCheckBox::indicator::checked { #_filesSelected {
border: 1px solid #5A5A5A; border-top-right-radius: 10px;
background: #5A5A5A; border-bottom-right-radius: 10px;
margin-bottom: 15px;
} }
QRadioButton::indicator:checked:hover, QCheckBox::indicator:checked:hover { #_toolbox {
border: 1px solid #DDDDDD; border-bottom-left-radius: 10px;
background: #DDDDDD; border-top-left-radius: 10px;
margin-bottom: 5px;
} }
QGroupBox { /* buttons */
margin-top: 6px; #_add_selectable_element {
border-radius: 5px;
border: 1px;
border-color: #085a00;
border-style: inset;
min-height: 20px;
padding-bottom: 2px;
padding-top: 2px;
margin-bottom: 20px;
}
#_add_selectable_element:hover {
background-color: #272727;
border-radius: 5px;
border: 2px;
border-color: #0ea800;
border-style: inset;
}
#_remove_selectable_element {
border-radius: 5px;
border: 1px;
border-color: #790909;
border-style: inset;
min-height: 20px;
padding-bottom: 2px;
padding-top: 2px;
margin-bottom: 20px;
} }
#_remove_selectable_element:hover {
QGroupBox::title { background-color: #272727;
top: -7px; border-radius: 5px;
left: 7px; border: 2px;
border-color: #cf0000;
border-style: inset;
} }
#_testButton {
color: rgb(255, 255, 255);
border-radius: 5px;
min-height: 20px;
font-size: 15px;
padding-bottom: 4px;
margin-top: 5px;
margin-bottom: 5px;
margin-right: 15px;
margin-left: 15px;
border: 1px;
border-color: #3a3a3a;
border-style: outset;
}
#_testButton:hover {
background-color: #c2c2c2;
color: rgb(0, 0, 0);
}
/* scrollbar */
QScrollBar { QScrollBar {
border: 1px solid #5A5A5A; border: 1px solid #5A5A5A;
background: #191919; background: #191919;
...@@ -147,35 +178,7 @@ QScrollBar::add-page, QScrollBar::sub-page { ...@@ -147,35 +178,7 @@ QScrollBar::add-page, QScrollBar::sub-page {
background: none; background: none;
} }
QAbstractButton:hover { /* image container */
background: #353535;
}
QAbstractButton:pressed {
background: #5A5A5A;
}
QAbstractItemView {
show-decoration-selected: 1;
selection-background-color: #3D7848;
selection-color: #DDDDDD;
alternate-background-color: #353535;
}
QHeaderView {
border: 1px solid #5A5A5A;
}
QHeaderView::section {
background: #191919;
border: 1px solid #5A5A5A;
padding: 4px;
}
QHeaderView::section:selected, QHeaderView::section::checked {
background: #353535;
}
QTableView { QTableView {
gridline-color: #5A5A5A; gridline-color: #5A5A5A;
} }
...@@ -185,7 +188,7 @@ QTabBar { ...@@ -185,7 +188,7 @@ QTabBar {
} }
QTabBar::tab { QTabBar::tab {
border-radius: 0px; border-top-right-radius: 4px;
padding: 4px; padding: 4px;
margin: 4px; margin: 4px;
} }
...@@ -194,38 +197,7 @@ QTabBar::tab:selected { ...@@ -194,38 +197,7 @@ QTabBar::tab:selected {
background: #353535; background: #353535;
} }
QComboBox::down-arrow { /**/
border: 1px solid #5A5A5A;
background: #353535;
}
QComboBox::drop-down {
border: 1px solid #5A5A5A;
background: #353535;
}
QComboBox::down-arrow {
width: 3px;
height: 3px;
border: 1px solid #5A5A5A;
}
QAbstractSpinBox {
padding-right: 15px;
}
QAbstractSpinBox::up-button, QAbstractSpinBox::down-button {
border: 1px solid #5A5A5A;
background: #353535;
subcontrol-origin: border;
}
QAbstractSpinBox::up-arrow, QAbstractSpinBox::down-arrow {
width: 3px;
height: 3px;
border: 1px solid #5A5A5A;
}
QSlider { QSlider {
border: none; border: none;
} }
...@@ -256,26 +228,19 @@ QSlider::handle:vertical { ...@@ -256,26 +228,19 @@ QSlider::handle:vertical {
} }
QSlider::add-page:vertical, QSlider::sub-page:horizontal { QSlider::add-page:vertical, QSlider::sub-page:horizontal {
background: #3D7848; background: #111381;
} }
QSlider::sub-page:vertical, QSlider::add-page:horizontal { QSlider::sub-page:vertical, QSlider::add-page:horizontal {
background: #353535; background: #353535;
} }
QLabel { /**/
border: none;
}
QProgressBar { QProgressBar {
text-align: center; text-align: center;
} }
QProgressBar::chunk { QProgressBar::chunk {
width: 1px; width: 1px;
background-color: #3D7848; background-color: #0e1875;
}
QMenu::separator {
background: #353535;
} }
/* QWidget::item:selected {
background: #4278db;
} */
/* menu */
QMenuBar {
background-color: #4375E3;
color: white;
}
/* menu items */
QMenuBar::item {
padding: 2px 20px 2px 20px;
border: 1px solid transparent;
}
QMenuBar::item:selected {
border-color: rgb(48, 83, 136);
background: #3859a1;
}
QMenuBar::item:pressed {
background: #2f477a;
}
/* boxes */
#_filesSelector {
border-bottom-right-radius: 10px;
background-color: white;
margin-bottom: 5px;
}
#_filesSelected {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
background-color: white;
margin-bottom: 15px;
}
#_toolbox {
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
background-color: white;
margin-bottom: 5px;
}
/* buttons */
#_add_selectable_element {
border-radius: 5px;
border: 1px;
border-color: #085a00;
border-style: inset;
min-height: 20px;
padding-bottom: 2px;
padding-top: 2px;
margin-bottom: 20px;
}
#_add_selectable_element:hover {
background-color: #dadada;
border-radius: 5px;
border: 2px;
border-color: #0ea800;
border-style: inset;
}
#_remove_selectable_element {
border-radius: 5px;
border: 1px;
border-color: #790909;
border-style: inset;
min-height: 20px;
padding-bottom: 2px;
padding-top: 2px;
margin-bottom: 20px;
}
#_remove_selectable_element:hover {
background-color: #dadada;
border-radius: 5px;
border: 2px;
border-color: #cf0000;
border-style: inset;
}
#_testButton {
background-color: #dadada;
color: rgb(0, 0, 0);
border-radius: 5px;
min-height: 20px;
font-size: 15px;
padding-bottom: 4px;
margin-top: 5px;
margin-bottom: 5px;
margin-right: 15px;
margin-left: 15px;
border: 1px;
border-color: #3a3a3a;
border-style: outset;
}
#_testButton:hover {
background-color: #c2c2c2;
color: rgb(0, 0, 0);
}
#include "editable.h"
namespace tool {
Editable::Editable(const QString & name, const QIcon & icon,bool free)
: Tool(name, icon), _free(free) {}
void Editable::onKeyPress(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &) {}
void Editable::onKeyReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &) {}
void Editable::pressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) {
if(image.rect().contains(click) || this->_free) {
this->onMousePressed(area, image, click, selection, e);
}
}
void Editable::released(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) {
if(image.rect().contains(click) || this->_free) {
this->onMouseReleased(area, image, click, selection, e);
}
}
void Editable::moved(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e, bool hold) {
if(image.rect().contains(click) || this->_free) {
this->onMouseMoved(area, image, click, selection, e, hold);
}
}
void Editable::keyPressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) {
this->onKeyPress(area, image, click, selection, e);
}
void Editable::keyReleased(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) {
this->onKeyReleased(area, image, click, selection, e);
}
}
#pragma once
#include "tool.h"
namespace tool {
class Editable : public Tool {
private:
bool _free;
public:
Editable(const QString & = "NaN", const QIcon & = QIcon(":/image/oxygen/icons/16x16/ressource/image/oxygen/icons/16x16/draw-freehand.png"), bool = false);
virtual void onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &) = 0;
virtual void onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &) = 0;
virtual void onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, bool) = 0;
virtual void onKeyPress(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &);
virtual void onKeyReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &);
public slots:
virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final;
virtual void released(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final;
virtual void moved(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &, bool) final;
virtual void keyPressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final;
virtual void keyReleased(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final;
};
}
#include "hand.h"
namespace tool {
Hand::Hand()
: Editable("Main", QIcon(":/image/oxygen/icons/16x16/ressource/image/oxygen/icons/16x16/transform-move.png"), true), _leftButton(false) {}
void Hand::onMousePressed(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e) {
if(e.button() == Qt::LeftButton) {
area.setCursor(QCursor(Qt::CursorShape::ClosedHandCursor));
this->_leftButton = true;
}
}
void Hand::onMouseReleased(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e) {
if(e.button() == Qt::LeftButton) {
area.setCursor(QCursor(Qt::CursorShape::OpenHandCursor));
area.setLast_Positon(e.pos());
this->_leftButton = false;
}
}
void Hand::onMouseMoved(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, bool hold) {
if(hold && this->_leftButton) {
QPoint move = e.pos() - area.last_position();
area.setPosition(QPoint(area.position().x() + move.x(),area.position().y() + move.y()));
area.setLast_Positon(e.pos());
}
}
}
#pragma once
#include "editable.h"
namespace tool {
class Hand : public Editable {
private:
bool _leftButton;
public:
Hand();
inline virtual Qt::CursorShape shape() const {return Qt::CursorShape::OpenHandCursor;}
virtual void onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &);
virtual void onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &);
virtual void onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, bool);
};
}
#pragma once
#include "tool.h"
namespace tool {
class Select : public Tool {
public:
Select(const QString &, const QIcon &);
virtual void setup() const = 0;
public slots:
virtual void use() const final;
};
}
#include "selectionnable.h"
namespace tool {
Selectionable::Selectionable(const QString & name, const QIcon & icon, bool free)
: Tool(name, icon), _free(free) {}
void Selectionable::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &) {}
void Selectionable::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &) {}
void Selectionable::pressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) {
if(image.rect().contains(click) || this->_free) {
this->onMousePressed(area, selection, click, image, e);
}
}
void Selectionable::released(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) {
if(image.rect().contains(click) || this->_free) {
this->onMouseReleased(area, selection, click, image, e);
}
}
void Selectionable::moved(ui::ImageArea & area, QImage & image, QPoint & click ,ui::Selection & selection, QMouseEvent & e, bool hold) {
if(image.rect().contains(click) || this->_free) {
this->onMouseMoved(area, selection, click, image, e, hold);
}
}
void Selectionable::keyPressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) {
this->onKeyPress(area, selection, click, image, e);
}
void Selectionable::keyReleased(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) {
this->onKeyReleased(area, selection, click, image, e);
}
}
#pragma once
#include "tool.h"
namespace tool {
class Selectionable : public Tool {
private:
bool _free;
public:
Selectionable(const QString & = "NaN", const QIcon & = QIcon(":/image/oxygen/icons/16x16/ressource/image/oxygen/icons/16x16/transform-crop.png"),bool = false);
virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &) = 0;
virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &) = 0;
virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, bool) = 0;
virtual void onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &);
virtual void onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &);
public slots:
virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final;
virtual void released(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final;
virtual void moved(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &, bool) final;
virtual void keyPressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final;
virtual void keyReleased(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final;
};
}
#pragma once #pragma once
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QObject>
#include <QCursor>
#include "../ui/view/imagearea.h"
namespace tool { namespace tool {
class Tool : public QListWidgetItem { class Tool : public QObject, public QListWidgetItem {
Q_OBJECT
public: public:
Tool(const QString &, const QIcon &); Tool(const QString &, const QIcon &);
virtual void use() const = 0; virtual inline Qt::CursorShape shape() const {return Qt::CursorShape::ArrowCursor;}
public slots:
virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0;
virtual void released(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0;
virtual void moved(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &, bool) = 0;
virtual void keyPressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) = 0;
virtual void keyReleased(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) = 0;
}; };
} }
...@@ -28,7 +28,6 @@ namespace ui { ...@@ -28,7 +28,6 @@ namespace ui {
this->_tree->setHeaderHidden(true); this->_tree->setHeaderHidden(true);
//this->_tree->setSortingEnabled(true); //this->_tree->setSortingEnabled(true);
QObject::connect(this->_tree, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(addItem(QModelIndex))); QObject::connect(this->_tree, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(addItem(QModelIndex)));
QObject::connect(this->_selected, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(select(QModelIndex))); QObject::connect(this->_selected, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(select(QModelIndex)));
} }
......
#include "displaymenulambda.h"
namespace ui {
DisplayMenuLambda::DisplayMenuLambda(ViewManager * manager)
: _manager(manager), _area(manager->currentView()) {
this->viewChange(this->_manager->currentView());
QObject::connect(this->_manager, SIGNAL(changedView(ImageArea*)), this, SLOT(viewChange(ImageArea*)));
}
void DisplayMenuLambda::initializeMenu(const QMenu * menu) {
this->_menu = menu;
}
void DisplayMenuLambda::viewChange(ImageArea *) {
if(this->_menu != nullptr) {
if(this->_area != nullptr) {
QObject::disconnect(this->_menu->actions().at(Actions::ZOOM_IN), SIGNAL(triggered()), this->_area, SLOT(increaseZoom()));
QObject::disconnect(this->_menu->actions().at(Actions::ZOOM_OUT), SIGNAL(triggered()), this->_area, SLOT(decreaseZoom()));
}
this->_area = this->_manager->currentView();
if(this->_area != nullptr) {
QObject::connect(this->_menu->actions().at(Actions::ZOOM_IN), SIGNAL(triggered()), this->_area, SLOT(increaseZoom()));
QObject::connect(this->_menu->actions().at(Actions::ZOOM_OUT), SIGNAL(triggered()), this->_area, SLOT(decreaseZoom()));
}
}
}
}
#pragma once
#include <QObject>
#include "menubarmanager.h"
#include "../view/viewmanager.h"
namespace ui {
class DisplayMenuLambda : public MenuLambda {
Q_OBJECT
private:
const QMenu * _menu;
ViewManager * _manager;
ImageArea * _area;
protected:
enum Actions : unsigned char {
ZOOM_IN = 0,
ZOOM_OUT = 1
};
public:
DisplayMenuLambda(ViewManager * manager);
virtual void initializeMenu(const QMenu *) final;
public slots:
void viewChange(ImageArea *);
};
}
...@@ -4,14 +4,18 @@ ...@@ -4,14 +4,18 @@
#include <QDebug> #include <QDebug>
namespace ui { namespace ui {
FilemenuLambda::FilemenuLambda(FileSelector * fileselector) FilemenuLambda::FilemenuLambda(FileSelector * fileselector, ViewManager * manager)
: _fileselector(fileselector) {} : _fileSelector(fileselector), _viewManager(manager) {}
FilemenuLambda::~FilemenuLambda() {} FilemenuLambda::~FilemenuLambda() {}
void FilemenuLambda::initializeMenu(const QMenu * menu) const { void FilemenuLambda::initializeMenu(const QMenu * menu) {
QObject::connect(menu->actions().at(Actions::QUIT), SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); QObject::connect(menu->actions().at(Actions::QUIT), SIGNAL(triggered()), QApplication::instance(), SLOT(quit()));
QObject::connect(menu->actions().at(Actions::OPEN), SIGNAL(triggered()), this->_fileselector, SLOT(pushItem())); QObject::connect(menu->actions().at(Actions::OPEN), SIGNAL(triggered()), this->_fileSelector, SLOT(pushItem()));
QObject::connect(menu->actions().at(Actions::OPEN_DIR), SIGNAL(triggered()), this->_fileselector, SLOT(setTreeRootPath())); QObject::connect(menu->actions().at(Actions::OPEN_DIR), SIGNAL(triggered()), this->_fileSelector, SLOT(setTreeRootPath()));
QObject::connect(menu->actions().at(Actions::SAVE), SIGNAL(triggered()), this->_viewManager, SLOT(saveCurrentView()));
QObject::connect(menu->actions().at(Actions::SAVE_AS), SIGNAL(triggered()), this->_viewManager, SLOT(saveAsCurrentView()));
QObject::connect(menu->actions().at(Actions::NEW), SIGNAL(triggered()), this->_viewManager, SLOT(newView()));
} }
} }
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
#include "menubarmanager.h" #include "menubarmanager.h"
#include "../files/fileselector.h" #include "../files/fileselector.h"
#include "../view/viewmanager.h"
namespace ui { namespace ui {
class FilemenuLambda : public MenuLambda { class FilemenuLambda : public MenuLambda {
Q_OBJECT
private: private:
FileSelector * _fileselector; FileSelector * _fileSelector;
ViewManager * _viewManager;
protected: protected:
enum Actions : unsigned char { enum Actions : unsigned char {
...@@ -21,9 +24,10 @@ namespace ui { ...@@ -21,9 +24,10 @@ namespace ui {
}; };
public: public:
FilemenuLambda(FileSelector *); FilemenuLambda(FileSelector *, ViewManager *);
virtual ~FilemenuLambda(); virtual ~FilemenuLambda();
virtual void initializeMenu(const QMenu *) const final;
virtual void initializeMenu(const QMenu *) final;
}; };
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment