diff --git a/capture/button.cpp b/capture/button.cpp index 0ad68c10..ee7ca9d3 100644 --- a/capture/button.cpp +++ b/capture/button.cpp @@ -51,8 +51,10 @@ Button::Button(Type t, QWidget *parent) : QPushButton(parent) { } +// getIcon returns the icon for the type of button, this method lets +// you choose between black or white icons (needed for the config menu) QIcon Button::getIcon(const Type t, bool isWhite) { - QString iconColor = "Black"; // or "Black" + QString iconColor = "Black"; if (isWhite) { iconColor = "White"; } @@ -117,9 +119,9 @@ QIcon Button::getIcon(const Type t, bool isWhite) { } return QIcon(path); } - +// get icon returns the icon for the type of button QIcon Button::getIcon(const Type t) { - // assign th isWhite based on the settings + // assign the isWhite based on the settings bool isWhite = true; return getIcon(t, isWhite); } @@ -135,7 +137,6 @@ void Button::leaveEvent(QEvent *e) { } void Button::mouseReleaseEvent(QMouseEvent *) { - if (m_buttonType == Type::mouseVisibility) { QSettings settings; bool mouseVisible = settings.value("mouseVisible").toBool(); @@ -144,9 +145,7 @@ void Button::mouseReleaseEvent(QMouseEvent *) { } else if (m_buttonType == Type::colorPicker) { } - Q_EMIT typeEmited(m_buttonType); - } void Button::animatedShow() { @@ -157,13 +156,14 @@ void Button::animatedShow() { Button::Type Button::getButtonType() const { return m_buttonType; } - +// getButtonBaseSize returns the base size of the buttons size_t Button::getButtonBaseSize() { return BUTTON_SIZE; } - +// getTypeByName receives a name and return the corresponding button type. +// returns Button::Type::last when the corresponding button is not found. Button::Type Button::getTypeByName(QString s) { - Button::Type res = Button::Type::line; + Button::Type res = Type::last; for (auto it = typeName.begin(); it != typeName.end(); ++it ) if (it->second == s) res = it->first; diff --git a/capture/button.h b/capture/button.h index 3e0ec16b..3f3aac22 100644 --- a/capture/button.h +++ b/capture/button.h @@ -49,7 +49,6 @@ public: last }; - explicit Button(Type, QWidget *parent = 0); static QIcon getIcon(const Type); @@ -68,6 +67,11 @@ protected: virtual void leaveEvent(QEvent *); virtual void mouseReleaseEvent(QMouseEvent *); +signals: + void hovered(); + void mouseExited(); + void typeEmited(Type); + private: Button(QWidget *parent = 0); Type m_buttonType; @@ -77,13 +81,6 @@ private: typedef std::map typeData; static typeData typeTooltip; static typeData typeName; - -signals: - void hovered(); - void mouseExited(); - void typeEmited(Type); - -public slots: }; #endif // BUTTON_H diff --git a/capture/buttonhandler.cpp b/capture/buttonhandler.cpp index 3bfbe3bf..e2724620 100644 --- a/capture/buttonhandler.cpp +++ b/capture/buttonhandler.cpp @@ -52,7 +52,10 @@ bool ButtonHandler::isVisible() const { size_t ButtonHandler::size() const { return m_vectorButtons.size(); } - +// updatePosition updates the position of the buttons arround the +// selection area. Ignores the sides blocked by the end of the screen. +// When the selection is too small it works on a virtual selection with +// the original in the center. void ButtonHandler::updatePosition(const QRect &selection, const QRect &limits) { const QVector::size_type vecLength = m_vectorButtons.size(); @@ -239,6 +242,9 @@ void ButtonHandler::updatePosition(const QRect &selection, } } +// getHPoints is an auxiliar method for the button position computation. +// starts from a known center and keeps adding elements horizontally +// and returns the computed positions. QVector ButtonHandler::getHPoints( const QPoint ¢er, const int elements) const { @@ -261,6 +267,9 @@ QVector ButtonHandler::getHPoints( return res; } +// getHPoints is an auxiliar method for the button position computation. +// starts from a known center and keeps adding elements vertically +// and returns the computed positions. QVector ButtonHandler::getVPoints( const QPoint ¢er, const int elements) const { @@ -282,7 +291,7 @@ QVector ButtonHandler::getVPoints( } return res; } - +// setButtons redefines the buttons of the button handler void ButtonHandler::setButtons(QVector