From d57ec2a21f9383aac2cbddd7df1af2bf0835455f Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Wed, 1 Jun 2011 16:52:50 +0200 Subject: [PATCH] system tray, edge, node initial steps --- Qt47supp.txt | 29 ++++++ README | 2 + aboutdialog.cpp | 18 ++++ aboutdialog.h | 22 ++++ aboutdialog.ui | 126 +++++++++++++++++++++++ edge.cpp | 104 +++++++++++++++++++ edge.h | 35 +++++++ graphwidget.cpp | 107 ++++++++++++++++++++ graphwidget.h | 32 ++++++ heart.svg | 55 ++++++++++ main.cpp | 75 +++++++++++++- mainwindow.cpp | 48 ++++++++- mainwindow.h | 12 +++ mainwindow.ui | 28 +++--- node.cpp | 73 ++++++++++++++ node.h | 34 +++++++ qtmindmap.pro | 21 +++- qtmindmap.pro.user | 244 +++++++++++++++++++++++++++++++++++++++++++++ qtmindmap.qrc | 5 + scrollarea.ui | 21 ++++ systemtray.cpp | 41 ++++++++ systemtray.h | 24 +++++ systemtray.ui | 21 ++++ 23 files changed, 1158 insertions(+), 19 deletions(-) create mode 100644 Qt47supp.txt create mode 100644 aboutdialog.cpp create mode 100644 aboutdialog.h create mode 100644 aboutdialog.ui create mode 100644 edge.cpp create mode 100644 edge.h create mode 100644 graphwidget.cpp create mode 100644 graphwidget.h create mode 100644 heart.svg create mode 100644 node.cpp create mode 100644 node.h create mode 100644 qtmindmap.pro.user create mode 100644 qtmindmap.qrc create mode 100644 scrollarea.ui create mode 100644 systemtray.cpp create mode 100644 systemtray.h create mode 100644 systemtray.ui diff --git a/Qt47supp.txt b/Qt47supp.txt new file mode 100644 index 0000000..1da4f51 --- /dev/null +++ b/Qt47supp.txt @@ -0,0 +1,29 @@ +{ + + Memcheck:Cond + fun:_ZN20QSharedMemoryPrivate6detachEv + fun:_ZN13QSharedMemory6detachEv + fun:_ZN13QSharedMemory6setKeyERK7QString + fun:_ZN13QSharedMemoryD1Ev + fun:_ZN20QRasterWindowSurface5flushEP7QWidgetRK7QRegionRK6QPoint + fun:_Z8qt_flushP7QWidgetRK7QRegionP14QWindowSurfaceS0_RK6QPoint + fun:_ZN19QWidgetBackingStore5flushEP7QWidgetP14QWindowSurface + fun:_ZN19QWidgetBackingStore8endPaintERK7QRegionP14QWindowSurfaceP14BeginPaintInfo + fun:_ZN19QWidgetBackingStore4syncEv + fun:_ZN14QWidgetPrivate16syncBackingStoreEv + fun:_ZN7QWidget5eventEP6QEvent + fun:_ZN11QMainWindow5eventEP6QEvent +} +{ + + Memcheck:Leak + fun:_Znwm + fun:_ZN18QtSimulatorPrivate15connectToServerEv + fun:_ZN18QtSimulatorPrivate19SimulatorConnection18connectToSimulatorEv + fun:_ZN18QtSimulatorPrivate19SimulatorConnection8instanceEv + fun:_ZN9QColormap10initializeEv + fun:_Z7qt_initP19QApplicationPrivatei + fun:_ZN19QApplicationPrivate9constructEv + fun:_ZN12QApplicationC1ERiPPci + fun:main +} diff --git a/README b/README index ea732a7..c26a89f 100644 --- a/README +++ b/README @@ -14,3 +14,5 @@ Let's do this project with Scrum. - taskbar app +TODO: +- set about dialog's size fiexd diff --git a/aboutdialog.cpp b/aboutdialog.cpp new file mode 100644 index 0000000..4371edf --- /dev/null +++ b/aboutdialog.cpp @@ -0,0 +1,18 @@ +#include "aboutdialog.h" +#include "ui_aboutdialog.h" + +//#include + +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + ui->setupUi(this); + connect(this, SIGNAL(finished(int)), parent, + SLOT(aboutDestroyed())); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} diff --git a/aboutdialog.h b/aboutdialog.h new file mode 100644 index 0000000..c4073ba --- /dev/null +++ b/aboutdialog.h @@ -0,0 +1,22 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +namespace Ui { + class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_H diff --git a/aboutdialog.ui b/aboutdialog.ui new file mode 100644 index 0000000..43b0e0e --- /dev/null +++ b/aboutdialog.ui @@ -0,0 +1,126 @@ + + + AboutDialog + + + true + + + + 0 + 0 + 329 + 142 + + + + + 0 + 0 + + + + About QtMindMap + + + false + + + + + 100 + 100 + 211 + 31 + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + 10 + 0 + 101 + 31 + + + + QtMindMap 0.1 + + + + + + 30 + 40 + 181 + 16 + + + + Mindmap software in QT + + + + + + 30 + 70 + 291 + 16 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Denes Matetelki <a href="mailto:denes.matetelki@gmail.com"><span style=" text-decoration: underline; color:#508ed8;">denes.matetelki@gmail.com</span></a></p></body></html> + + + Qt::RichText + + + + + + + buttonBox + accepted() + AboutDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AboutDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/edge.cpp b/edge.cpp new file mode 100644 index 0000000..5c2e418 --- /dev/null +++ b/edge.cpp @@ -0,0 +1,104 @@ +#include + +#include "edge.h" +#include "node.h" + +#include + +static const double Pi = 3.14159265358979323846264338327950288419717; +static double TwoPi = 2.0 * Pi; + +Edge::Edge(Node *sourceNode, Node *destNode) + : arrowSize(10) +{ + setAcceptedMouseButtons(0); + source = sourceNode; + dest = destNode; + source->addEdge(this); + dest->addEdge(this); + adjust(); + setZValue(1); +} + +Node *Edge::sourceNode() const +{ + return source; +} + +Node *Edge::destNode() const +{ + return dest; +} + +void Edge::adjust() +{ + if (!source || !dest) + return; + + QLineF line(mapFromItem(source, 0, 0) + source->boundingRect().center(), + mapFromItem(dest, 0, 0) + dest->boundingRect().center()); + qreal length = line.length(); + + prepareGeometryChange(); + + if (length > qreal(20.)) { +// QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length); +// QPointF sourceOffset( ); +// if ( source->contains( source->boundingRect().center() + source->boundingRect().height() / 2 / tan(line.angle())), +// source->boundingRect().width() / 2 ) +// { +// sourcePoint = line.p1() + QPointF( , tan( line.angle() ) * source->boundingRect().height() / 2 ); +// } + + sourcePoint = line.p1(); + destPoint = line.p2(); + } else { + sourcePoint = destPoint = line.p1(); + } +} + +QRectF Edge::boundingRect() const +{ + if (!source || !dest) + return QRectF(); + + qreal penWidth = 1; + qreal extra = (penWidth + arrowSize) / 2.0; + + return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(), + destPoint.y() - sourcePoint.y())) + .normalized() + .adjusted(-extra, -extra, extra, extra); +} + +void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + if (!source || !dest) + return; + + QLineF line(sourcePoint, destPoint); + if (qFuzzyCompare(line.length(), qreal(0.))) + return; + + // Draw the line itself + painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter->drawLine(line); + + // Draw the arrows + double angle = ::acos(line.dx() / line.length()); + if (line.dy() >= 0) + angle = TwoPi - angle; + +// QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize, +// cos(angle + Pi / 3) * arrowSize); +// QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize, +// cos(angle + Pi - Pi / 3) * arrowSize); + QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize, + cos(angle - Pi / 3) * arrowSize); + QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize, + cos(angle - Pi + Pi / 3) * arrowSize); + + painter->setBrush(Qt::black); +// painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2); + painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2); +} diff --git a/edge.h b/edge.h new file mode 100644 index 0000000..b8d1648 --- /dev/null +++ b/edge.h @@ -0,0 +1,35 @@ +#ifndef EDGE_H +#define EDGE_H + +#include + +class Node; + +class Edge : public QGraphicsItem +{ +// Q_OBJECT + +public: + Edge(Node *sourceNode, Node *destNode); + + Node *sourceNode() const; + Node *destNode() const; + + void adjust(); + + enum { Type = UserType + 2 }; + int type() const { return Type; } + +protected: + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +private: + Node *source, *dest; + + QPointF sourcePoint; + QPointF destPoint; + qreal arrowSize; +}; + +#endif diff --git a/graphwidget.cpp b/graphwidget.cpp new file mode 100644 index 0000000..8769d4d --- /dev/null +++ b/graphwidget.cpp @@ -0,0 +1,107 @@ +#include "graphwidget.h" +#include +#include "node.h" + +//#include +#include "edge.h" +#include "math.h" + +GraphWidget::GraphWidget(QWidget *parent) +{ + qDebug() << __PRETTY_FUNCTION__; + + scene = new QGraphicsScene(this); + scene->setItemIndexMethod(QGraphicsScene::NoIndex); + scene->setSceneRect(-200, -200, 400, 400); + setScene(scene); + setCacheMode(CacheBackground); + setViewportUpdateMode(BoundingRectViewportUpdate); + setRenderHint(QPainter::Antialiasing); + setTransformationAnchor(AnchorUnderMouse); + scale(qreal(0.8), qreal(0.8)); + setMinimumSize(400, 400); + + +// node1 = new Node(this); +// scene->addItem(node1); +// node1->setPos(0, 0); + Node *node1 = new Node(); + node1->setHtml(QString("salalal")); + scene->addItem(node1); + node1->setPos(-100, -100); + + Node *node2 = new Node(); + node2->setHtml(QString("denes is\na really nice person")); + scene->addItem(node2); + node2->setPos(100, 100); + + +// QGraphicsTextItem *item = new QGraphicsTextItem(); +// item->setPlainText(QString("salalal")); +// scene->addItem(item); +// item->setPos(20, 20); +// item->setFlag(QGraphicsItem::ItemIsMovable); +// item->setFlag(QGraphicsItem::ItemSendsGeometryChanges); +// item->setCacheMode(QGraphicsItem::DeviceCoordinateCache); +// item->setZValue(-1); + +// QGraphicsTextItem *item2 = new QGraphicsTextItem(); +// item2->setHtml(QString("denes is\na really nice person")); +// scene->addItem(item2); +// item2->setPos(10, 10); +// item2->setFlag(QGraphicsItem::ItemIsMovable); +// item2->setFlag(QGraphicsItem::ItemSendsGeometryChanges); +// item2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); +// item2->setZValue(-1); + + scene->addItem(new Edge(node1, node2)); + activeNode = node1; + activeNode->setFocus(); +} + + +void GraphWidget::keyPressEvent(QKeyEvent *event) + { + switch (event->key()) { +// case Qt::Key_Up: +// centerNode->moveBy(0, -20); +// break; +// case Qt::Key_Down: +// centerNode->moveBy(0, 20); +// break; +// case Qt::Key_Left: +// centerNode->moveBy(-20, 0); +// break; +// case Qt::Key_Right: +// centerNode->moveBy(20, 0); +// break; + case Qt::Key_Plus: + scaleView(qreal(1.2)); + break; + case Qt::Key_Minus: + scaleView(1 / qreal(1.2)); + break; +// case Qt::Key_Space: +// case Qt::Key_Enter: +// foreach (QGraphicsItem *item, scene()->items()) { +// if (qgraphicsitem_cast(item)) +// item->setPos(-150 + qrand() % 300, -150 + qrand() % 300); +// } +// break; + default: + QGraphicsView::keyPressEvent(event); + } + } + +void GraphWidget::wheelEvent(QWheelEvent *event) +{ + scaleView(pow((double)2, -event->delta() / 240.0)); +} + +void GraphWidget::scaleView(qreal scaleFactor) +{ + qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); + if (factor < 0.2 || factor > 10) return; + + scale(scaleFactor, scaleFactor); +} diff --git a/graphwidget.h b/graphwidget.h new file mode 100644 index 0000000..1011792 --- /dev/null +++ b/graphwidget.h @@ -0,0 +1,32 @@ +#ifndef GRAPHWIDGET_H +#define GRAPHWIDGET_H + +#include +#include +#include + +#include "node.h" + +//class Node; + +class GraphWidget : public QGraphicsView +{ + Q_OBJECT + + +public: + GraphWidget(QWidget *parent = 0); + +protected: +// void drawBackground(QPainter *painter, const QRectF &rect); + void keyPressEvent(QKeyEvent *event); + void wheelEvent(QWheelEvent *event); + void scaleView(qreal scaleFactor); + +private: + Node *activeNode; + QGraphicsScene *scene; + +}; + +#endif // GRAPHWIDGET_H diff --git a/heart.svg b/heart.svg new file mode 100644 index 0000000..86be447 --- /dev/null +++ b/heart.svg @@ -0,0 +1,55 @@ + + + + + +Heart Left-Highlight +This is a normal valentines day heart. + + +holiday +valentines + +valentine +hash(0x8a091c0) +hash(0x8a0916c) +signs_and_symbols +hash(0x8a091f0) +day + + + + +Jon Phillips + + + + +Jon Phillips + + + + +Jon Phillips + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main.cpp b/main.cpp index 9ae175b..d0d02b7 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,82 @@ -#include +#include // EXIT_SUCCESS +#include // cout + +#include +//#include +#include +#include + #include "mainwindow.h" +#include "systemtray.h" + + +void printUsage() +{ + std::cout << "Usage: qtmindmap [OPTION][FILE]" << std::endl + << "Mindmap program in QT" << std::endl + << std::endl + << "Options:" << std::endl + << "-h, --help\tPrints this help." << std::endl + << "-t, --tray\tStarts application in system tray." << std::endl + << std::endl + << "Report bugs to: denes.matetelki@gmail.com" << std::endl; +} + + +bool parseCmdLineArgs(bool &isSystemTray, QString &filePath) +{ + QStringList cmdlineArgs = QCoreApplication::arguments(); + cmdlineArgs.removeFirst(); + + QRegExp help("^-(h|-help)$"); + if (!cmdlineArgs.filter(help).isEmpty()) return false; + + QRegExp tray("^-(t|-tray)$"); + if (!cmdlineArgs.filter(tray).isEmpty()) isSystemTray = true; + + QRegExp all("^-(t|-tray|h|-help)$"); + QStringList others; + foreach (QString arg, cmdlineArgs) if (all.indexIn(arg)==-1) others.append(arg); + if (others.size() > 1) return false; + + if (others.size()==1) filePath = others.first(); + + return true; +} + int main(int argc, char *argv[]) { + Q_INIT_RESOURCE(qtmindmap); + QApplication a(argc, argv); + + bool isSystemTray(false); + QString filePath; + if (!parseCmdLineArgs(isSystemTray,filePath)) + { + printUsage(); + return EXIT_FAILURE; + } + MainWindow w; - w.show(); + SystemTray *systemTray; + isSystemTray = true; + if (isSystemTray) + { + if (!QSystemTrayIcon::isSystemTrayAvailable()) + { + QMessageBox::critical(0, + QObject::tr("Systray"), + QObject::tr("I couldn't detect any system tray on this system.")); + return EXIT_FAILURE; + } + QApplication::setQuitOnLastWindowClosed(false); + systemTray = new SystemTray(&w); + systemTray->show(); + } + + w.show(); return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 49d64fc..88ac80a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,14 +1,60 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include "aboutdialog.h" + +#include +//#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), - ui(new Ui::MainWindow) + ui(new Ui::MainWindow), + aboutDialog(0) { + qDebug() << __PRETTY_FUNCTION__; ui->setupUi(this); + connect(ui->actionNew, SIGNAL(activated()), this, SLOT(klakk())); + connect(ui->actionOpen, SIGNAL(activated()), this, SLOT(klakk())); + connect(ui->actionSave, SIGNAL(activated()), this, SLOT(klakk())); + connect(ui->actionClose, SIGNAL(activated()), this, SLOT(klakk())); + connect(ui->actionQuit, SIGNAL(activated()), QApplication::instance(), + SLOT(closeAllWindows())); + connect(ui->actionAbout_QtMindMap, SIGNAL(activated()), this, + SLOT(about())); + + graphicsView = new GraphWidget(ui->centralWidget); + setCentralWidget(graphicsView); + } MainWindow::~MainWindow() { + qDebug() << __PRETTY_FUNCTION__; delete ui; + if (aboutDialog) delete aboutDialog; +} + +void MainWindow::klakk() +{ + qDebug() << __PRETTY_FUNCTION__; +} + +void MainWindow::about() +{ + qDebug() << __PRETTY_FUNCTION__; + + setDisabled(true); + if (aboutDialog == 0) aboutDialog = new AboutDialog(this); + aboutDialog->setEnabled(true); // children inherits enabled status + aboutDialog->show(); +// aboutDialog->layout()->setSizeConstraint( QLayout::SetFixedSize ); +} + +void MainWindow::aboutDestroyed() +{ + qDebug() << __PRETTY_FUNCTION__; + qDebug() << aboutDialog; + setEnabled(true); + } + + diff --git a/mainwindow.h b/mainwindow.h index c9fd6a9..9261f37 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -2,6 +2,10 @@ #define MAINWINDOW_H #include +//#include + +#include "aboutdialog.h" +#include "graphwidget.h" namespace Ui { class MainWindow; @@ -15,8 +19,16 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); +public slots: + void klakk(void); + void about(); + void aboutDestroyed(); + private: Ui::MainWindow *ui; + AboutDialog* aboutDialog; +// QPointer aboutDialog; + GraphWidget *graphicsView; }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 14b367a..6f99741 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,12 +6,12 @@ 0 0 - 400 - 300 + 438 + 349 - MainWindow + QtMindMap @@ -19,13 +19,13 @@ 0 0 - 400 + 438 23 - File + &File @@ -36,7 +36,7 @@ - Help + &Help @@ -54,7 +54,7 @@ - New + &New Ctrl+N @@ -62,7 +62,7 @@ - Open + &Open Ctrl+O @@ -70,7 +70,7 @@ - Save + &Save Ctrl+S @@ -78,7 +78,7 @@ - Quit + &Quit Ctrl+Q @@ -86,12 +86,12 @@ - About QtMindMap + &About QtMindMap - Close + &Close Ctrl+W @@ -101,4 +101,8 @@ + + cica() + rdfgdfg() + diff --git a/node.cpp b/node.cpp new file mode 100644 index 0000000..1b90498 --- /dev/null +++ b/node.cpp @@ -0,0 +1,73 @@ +#include "node.h" + +#include +#include +#include + +Node::Node(GraphWidget *parent) : graph(parent), active(false) +{ + qDebug() << __PRETTY_FUNCTION__; + + setFlag(ItemIsMovable); + setFlag(ItemSendsGeometryChanges); + setCacheMode(DeviceCoordinateCache); + setZValue(2); + + // shall I set it after some spec key? + setTextInteractionFlags(Qt::TextEditorInteraction); +} + +void Node::addEdge(Edge *edge) +{ + qDebug() << __PRETTY_FUNCTION__; + + edgeList << edge; + edge->adjust(); +} + + +QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) +{ + qDebug() << __PRETTY_FUNCTION__; + + switch (change) { + case ItemPositionHasChanged: + foreach (Edge *edge, edgeList) edge->adjust(); + // graph->itemMoved(); + break; + default: + break; + }; + + return QGraphicsItem::itemChange(change, value); +} + +void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + qDebug() << __PRETTY_FUNCTION__; + +// active = true; +// setScale(1.2); + update(); + QGraphicsTextItem::mousePressEvent(event); +} + +void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + qDebug() << __PRETTY_FUNCTION__; + +// active = false; +// setScale(1.0); + update(); + QGraphicsTextItem::mouseReleaseEvent(event); +} + +//void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +//{ +// qDebug() << __PRETTY_FUNCTION__; +// QGraphicsTextItem::paint(painter, option, widget); + +// qDebug() << "I " << (hasFocus() ? "have " : "don't have ") << "focus."; +// setScale(hasFocus() ? 1.2 : 1.0); +//// setScale(active ? 1.2 : 1.0); +//} diff --git a/node.h b/node.h new file mode 100644 index 0000000..41393d6 --- /dev/null +++ b/node.h @@ -0,0 +1,34 @@ +#ifndef NODE_H +#define NODE_H + +#include + +#include "edge.h" +#include "graphwidget.h" + +class GraphWidget; + +class Node : public QGraphicsTextItem +{ +// Q_OBJECT + +public: + Node(GraphWidget *graphWidget = 0); + + void addEdge(Edge *edge); + QList edges() const; + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); +// void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +private: + QList edgeList; + GraphWidget *graph; + bool active; + +}; + +#endif // NODE_H diff --git a/qtmindmap.pro b/qtmindmap.pro index d0ba429..90af67f 100644 --- a/qtmindmap.pro +++ b/qtmindmap.pro @@ -4,15 +4,28 @@ # #------------------------------------------------- -QT += core gui +QT += core gui svg TARGET = qtmindmap TEMPLATE = app SOURCES += main.cpp\ - mainwindow.cpp + mainwindow.cpp \ + aboutdialog.cpp \ + graphwidget.cpp \ + node.cpp \ + edge.cpp \ + systemtray.cpp -HEADERS += mainwindow.h +HEADERS += mainwindow.h \ + aboutdialog.h \ + graphwidget.h \ + node.h \ + edge.h \ + systemtray.h -FORMS += mainwindow.ui +FORMS += mainwindow.ui \ + aboutdialog.ui + +RESOURCES = qtmindmap.qrc diff --git a/qtmindmap.pro.user b/qtmindmap.pro.user new file mode 100644 index 0000000..675c486 --- /dev/null +++ b/qtmindmap.pro.user @@ -0,0 +1,244 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + System + false + false + 4 + true + 1 + true + false + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 1 + 0 + 0 + + ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit. + + + qmake + + QtProjectManager.QMakeBuildStep + false + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt in PATH Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/cs0rbagomba/projects/qtmindmap-build-desktop + 2 + ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit. + true + + + ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit. + + + qmake + + QtProjectManager.QMakeBuildStep + false + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt in PATH Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + 2 + ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit. + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + true + 25 + + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + qtmindmap + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + qtmindmap.pro + false + false + + + 3768 + true + false + + + + true + 25 + + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + -q --tool=memcheck --leak-check=full --leak-resolution=low --suppressions=../qtmindmap/Qt47supp.txt ./qtmindmap + 2 + valgrind + false + + /home/cs0rbagomba/projects/qtmindmap-build-desktop + Run valgrind + + ProjectExplorer.CustomExecutableRunConfiguration + 3768 + true + false + + 2 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {75e4e232-a182-46a5-bb12-10bf44c99a73} + + + ProjectExplorer.Project.Updater.FileVersion + 9 + + diff --git a/qtmindmap.qrc b/qtmindmap.qrc new file mode 100644 index 0000000..ffe32ab --- /dev/null +++ b/qtmindmap.qrc @@ -0,0 +1,5 @@ + + + heart.svg + + \ No newline at end of file diff --git a/scrollarea.ui b/scrollarea.ui new file mode 100644 index 0000000..a3c87cd --- /dev/null +++ b/scrollarea.ui @@ -0,0 +1,21 @@ + + + ScrollArea + + + true + + + + 0 + 0 + 400 + 300 + + + + ScrollArea + + + + diff --git a/systemtray.cpp b/systemtray.cpp new file mode 100644 index 0000000..db48d98 --- /dev/null +++ b/systemtray.cpp @@ -0,0 +1,41 @@ +#include "systemtray.h" + + +#include +//#include +//#include + +SystemTray::SystemTray(MainWindow* parent) + : QSystemTrayIcon(parent), + mainWindow(parent) +{ + // QSystemTrayIcon *trayIcon; + + + minimizeAction = new QAction(tr("Mi&nimize"), this); + connect(minimizeAction, SIGNAL(triggered()), parent, SLOT(hide())); + + maximizeAction = new QAction(tr("Ma&ximize"), this); + connect(maximizeAction, SIGNAL(triggered()), parent, SLOT(showMaximized())); + + restoreAction = new QAction(tr("&Restore"), this); + connect(restoreAction, SIGNAL(triggered()), parent, SLOT(showNormal())); + + quitAction = new QAction(tr("&Quit"), this); + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + /// @BUG shall pass this as parent + trayIconMenu = new QMenu(0); + trayIconMenu->addAction(minimizeAction); + trayIconMenu->addAction(maximizeAction); + trayIconMenu->addAction(restoreAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(quitAction); + +// trayIcon = new QSystemTrayIcon(this); +// trayIcon->setContextMenu(trayIconMenu); + setContextMenu(trayIconMenu); + + icon = new QIcon(":/heart.svg"); + setIcon(QIcon(":/heart.svg")); +} diff --git a/systemtray.h b/systemtray.h new file mode 100644 index 0000000..fe697fc --- /dev/null +++ b/systemtray.h @@ -0,0 +1,24 @@ +#ifndef SYSTEMTRAY_H +#define SYSTEMTRAY_H + +#include +#include "mainwindow.h" + +class SystemTray : public QSystemTrayIcon +{ +// Q_OBJECT + +public: + SystemTray(MainWindow *parent = 0); + +private: + MainWindow *mainWindow; + QMenu *trayIconMenu; + QAction *minimizeAction; + QAction *maximizeAction; + QAction *restoreAction; + QAction *quitAction; + QIcon *icon; +}; + +#endif // SYSTEMTRAY_H diff --git a/systemtray.ui b/systemtray.ui new file mode 100644 index 0000000..5e52dc7 --- /dev/null +++ b/systemtray.ui @@ -0,0 +1,21 @@ + + + + + SystemTray + + + + 0 + 0 + 400 + 300 + + + + Form + + + + +