From 0c41aecfc91661bbe484ecf8cb9d534957357d78 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 9 Jun 2015 14:09:12 +0200 Subject: [PATCH] ui: reworded file tooltips * and added sample source --- bin/app/data/src/sample/draw.cpp | 129 ++++++++++++++++++++++++++++ bin/app/data/src/sample/samples.cpp | 123 ++++++++++++++++++++++++++ src/app/qt/element/QtCodeFile.cpp | 6 +- 3 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 bin/app/data/src/sample/draw.cpp create mode 100644 bin/app/data/src/sample/samples.cpp diff --git a/bin/app/data/src/sample/draw.cpp b/bin/app/data/src/sample/draw.cpp new file mode 100644 index 00000000..f6d3a23b --- /dev/null +++ b/bin/app/data/src/sample/draw.cpp @@ -0,0 +1,129 @@ +class Point +{ +public: + Point(int x, int y) + : x(x) + , y(y) + { + } + + int x; + int y; +}; + + +class Shape +{ +public: + virtual void draw() = 0; +}; + + +class Line + : public Shape +{ +public: + Line(Point start, Point end) + : start(start) + , end(end) + { + } + + void draw() + { + // line drawing + } + +private: + Point start; + Point end; +}; + + +class Circle + : public Shape +{ +public: + Circle(Point center, int radius) + : center(center) + , radius(radius) + {} + + void draw() + { + // circle drawing + } + +private: + Point center; + int radius; +}; + + +class Image +{ +public: + Image(int width, int height) + : width(width) + , height(height) + , idx(0) + { + shapes = new Shape*[10]; + } + + ~Image() + { + for (int i = 0; i < idx; i++) + { + delete shapes[i]; + } + + delete [] shapes; + } + + void addShape(Shape* shape) + { + if (idx < 10) + { + shapes[idx] = shape; + idx++; + } + } + + void draw() + { + for (int i = 0; i < idx; i++) + { + shapes[i]->draw(); + } + } + +private: + Shape** shapes; + int idx; + + int width; + int height; +}; + + +void drawStickMan() +{ + Image stickman(100, 200); + + // head + stickman.addShape(new Circle(Point(50, 50), 25)); + + // torso + stickman.addShape(new Line(Point(50, 75), Point(50, 180))); + + // arms + stickman.addShape(new Line(Point(50, 100), Point(10, 125))); + stickman.addShape(new Line(Point(50, 100), Point(90, 125))); + + // legs + stickman.addShape(new Line(Point(50, 100), Point(10, 125))); + stickman.addShape(new Line(Point(50, 100), Point(90, 125))); + + stickman.draw(); +} diff --git a/bin/app/data/src/sample/samples.cpp b/bin/app/data/src/sample/samples.cpp new file mode 100644 index 00000000..96ea4cb0 --- /dev/null +++ b/bin/app/data/src/sample/samples.cpp @@ -0,0 +1,123 @@ + +int number = 3; + +int calculate() +{ + int a = 1 + 2; + return a; +} + + +int count = 0; + +void countUp() +{ + count += 1; +} + +void countDown() +{ + count -= 1; +} + + +void countUpTen() +{ + for (int i = 0; i < 10; i++) + { + countUp(); + } +} + + +class Person +{ +public: + Person(char* name) + : name(name) + , age(0) + , weight(3) + , height(50) + { + } + + char* askForName() const + { + return name; + } + + void gainWeight(int gain) + { + weight += gain; + } + + void grow(int gain) + { + height += gain; + } + + void celebrateBirthday() + { + age += 1; + + grow(5); + gainWeight(3); + } + +private: + char* name; + int age; + + int height; + int weight; +}; + + +class Vehicle +{ +protected: + int wheelCount; + int seatCount; +}; + +class Car + : public Vehicle +{ +public: + Car() + { + wheelCount = 4; + seatCount = 5; + } +}; + +class Truck + : public Vehicle +{ +public: + Truck() + { + wheelCount = 6; + seatCount = 2; + } +}; + + +template +T sum(T a, T b) +{ + return a + b; +} + +class Apple {}; +class Pear {}; + +template +class Basket +{ +public: + Fruit** field; +}; + +Basket apples; +Basket pears; diff --git a/src/app/qt/element/QtCodeFile.cpp b/src/app/qt/element/QtCodeFile.cpp index 7f02b500..d793e908 100644 --- a/src/app/qt/element/QtCodeFile.cpp +++ b/src/app/qt/element/QtCodeFile.cpp @@ -46,19 +46,19 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent) m_minimizeButton = new QPushButton(this); m_minimizeButton->setObjectName("minimize_button"); - m_minimizeButton->setToolTip("minimize file"); + m_minimizeButton->setToolTip("minimize"); m_minimizeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac titleLayout->addWidget(m_minimizeButton); m_snippetButton = new QPushButton(this); m_snippetButton->setObjectName("snippet_button"); - m_snippetButton->setToolTip("show snippets in file"); + m_snippetButton->setToolTip("show snippets"); m_snippetButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac titleLayout->addWidget(m_snippetButton); m_maximizeButton = new QPushButton(this); m_maximizeButton->setObjectName("maximize_button"); - m_maximizeButton->setToolTip("maximize file"); + m_maximizeButton->setToolTip("maximize"); m_maximizeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac titleLayout->addWidget(m_maximizeButton);