diff --git a/sources/kbe/kbe.pro b/sources/kbe/kbe.pro index 4e89319..0daf7c4 100644 --- a/sources/kbe/kbe.pro +++ b/sources/kbe/kbe.pro @@ -52,3 +52,6 @@ MOC_DIR = moc OTHER_FILES += \ media/stylesheets/projectmanager.qss + +DISTFILES += \ + media/stylesheets/tooltipstyle.css diff --git a/sources/kbe/kbe.qrc b/sources/kbe/kbe.qrc index 45fdb46..efd3ffc 100644 --- a/sources/kbe/kbe.qrc +++ b/sources/kbe/kbe.qrc @@ -25,5 +25,6 @@ media/icons/pm-collapse.png media/icons/pm-expand.png media/icons/pm-add.png + media/stylesheets/tooltipstyle.css diff --git a/sources/kbe/main.cpp b/sources/kbe/main.cpp index 85431e1..29f5222 100644 --- a/sources/kbe/main.cpp +++ b/sources/kbe/main.cpp @@ -35,6 +35,12 @@ int main(int argc, char *argv[]) a.setAttribute(Qt::AA_DontShowIconsInMenus, false); + /*Set tooltip style*/ + QFile styleFile(":/media/stylesheets/tooltipstyle.css"); + styleFile.open(QFile::ReadOnly); + QString styleSheet = QLatin1String(styleFile.readAll()); + a.setStyleSheet(styleSheet); + QDir binPath(QCoreApplication::applicationDirPath()); /* Set working directory */ diff --git a/sources/kbe/media/stylesheets/tooltipstyle.css b/sources/kbe/media/stylesheets/tooltipstyle.css new file mode 100644 index 0000000..3d1a2ef --- /dev/null +++ b/sources/kbe/media/stylesheets/tooltipstyle.css @@ -0,0 +1,6 @@ +QToolTip { + background-color: black; + color: white; + opacity: 200%; + padding: 3px; +} diff --git a/sources/plugins/scg/media/video/arc_mode.gif b/sources/plugins/scg/media/video/arc_mode.gif new file mode 100644 index 0000000..6e4c9c0 Binary files /dev/null and b/sources/plugins/scg/media/video/arc_mode.gif differ diff --git a/sources/plugins/scg/media/video/bus_mode.gif b/sources/plugins/scg/media/video/bus_mode.gif new file mode 100644 index 0000000..8522bcb Binary files /dev/null and b/sources/plugins/scg/media/video/bus_mode.gif differ diff --git a/sources/plugins/scg/media/video/contour_mode.gif b/sources/plugins/scg/media/video/contour_mode.gif new file mode 100644 index 0000000..f7dcdfe Binary files /dev/null and b/sources/plugins/scg/media/video/contour_mode.gif differ diff --git a/sources/plugins/scg/media/video/selection_mode.gif b/sources/plugins/scg/media/video/selection_mode.gif new file mode 100644 index 0000000..382359e Binary files /dev/null and b/sources/plugins/scg/media/video/selection_mode.gif differ diff --git a/sources/plugins/scg/scg.pro b/sources/plugins/scg/scg.pro index f02268c..5c3aa5c 100644 --- a/sources/plugins/scg/scg.pro +++ b/sources/plugins/scg/scg.pro @@ -19,6 +19,7 @@ win32 { } HEADERS += \ + scgactionwithvideotooltip.h \ scgwindow.h \ scgview.h \ scgtemplateobjectbuilder.h \ @@ -98,6 +99,7 @@ HEADERS += \ scgtypedialog.h SOURCES += \ + scgactionwithvideotooltip.cpp \ scgwindow.cpp \ scgview.cpp \ scgtemplateobjectbuilder.cpp \ diff --git a/sources/plugins/scg/scg.qrc b/sources/plugins/scg/scg.qrc index 3bc30fc..b024219 100644 --- a/sources/plugins/scg/scg.qrc +++ b/sources/plugins/scg/scg.qrc @@ -31,5 +31,9 @@ media/icons/tool-select-subgraph.png media/translations/scg_en_EN.qm media/translations/scg_ru_RU.qm + media/video/arc_mode.gif + media/video/bus_mode.gif + media/video/contour_mode.gif + media/video/selection_mode.gif diff --git a/sources/plugins/scg/scgactionwithvideotooltip.cpp b/sources/plugins/scg/scgactionwithvideotooltip.cpp new file mode 100644 index 0000000..f9a0069 --- /dev/null +++ b/sources/plugins/scg/scgactionwithvideotooltip.cpp @@ -0,0 +1,57 @@ +#include "scgactionwithvideotooltip.h" + +#include +#include +#include +#include +#include +#include + + +ActionWithVideoTooTip::ActionWithVideoTooTip(const QString text, const QString& gifPath,QWidget *parent) : QWidget(parent) +{ + wid = new QWidget(); + wid->setWindowOpacity(0.8); + movie = new QMovie(gifPath); + label = new QLabel(); + QLabel* about = new QLabel(); + about->setText(text); + about->setStyleSheet("color: white;"); + label->setFixedSize(330, 200); + QVBoxLayout * mainLayout = new QVBoxLayout(); + label->setMovie(movie); + + mainLayout->addWidget(label); + mainLayout->addWidget(about); + wid->setLayout(mainLayout); + wid->setWindowFlags(Qt::FramelessWindowHint); + wid->setStyleSheet("background-color: black;"); + wid->hide(); +} + +//overriding event method to catch if tooltip requested +bool ActionWithVideoTooTip::event(QEvent *event) +{ + //filter events + if (event->type() == QEvent::ToolTip){ + + // Set the size of the widget to the size of the movie + //set timeout before show + sleep(0.4); + // start animation + movie->start(); + // get cursor position + QPoint pl = QCursor::pos(); + //move widget avay from QAction + wid->move(pl.rx()+15, pl.ry()); + wid->show(); + } + if(event->type()==QEvent::Leave) + { + //hide widget when tooltip dont need anymore + movie->stop(); + wid->hide(); + } + // return parent method + return QWidget::event(event); +} diff --git a/sources/plugins/scg/scgactionwithvideotooltip.h b/sources/plugins/scg/scgactionwithvideotooltip.h new file mode 100644 index 0000000..1bbcc1c --- /dev/null +++ b/sources/plugins/scg/scgactionwithvideotooltip.h @@ -0,0 +1,29 @@ +/* + * This source file is part of an OSTIS project. For the latest info, see http://ostis.net + * Distributed under the MIT License + * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +class ActionWithVideoTooTip : public QWidget +{ + Q_OBJECT +public: + ActionWithVideoTooTip(const QString text, const QString& gifPath, QWidget *parent= nullptr); + +protected: + virtual bool event(QEvent *event) override; +private: + QMovie *movie; + QLabel *label; + QWidget * wid; + +}; diff --git a/sources/plugins/scg/scgwindow.cpp b/sources/plugins/scg/scgwindow.cpp index df489f3..1ed336e 100644 --- a/sources/plugins/scg/scgwindow.cpp +++ b/sources/plugins/scg/scgwindow.cpp @@ -43,6 +43,7 @@ #include "scgtemplateobjectbuilder.h" #include "config.h" #include "scgundoview.h" +#include "scgactionwithvideotooltip.h" const QString SCgWindow::SupportedPasteMimeType = "text/KBE-gwf"; @@ -167,7 +168,7 @@ void SCgWindow::createToolBar() QActionGroup* group = new QActionGroup(mToolBar); // Select mode - QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar); + QAction *action = new QAction(findIcon("tool-select.png"), tr(""), mToolBar); action->setCheckable(true); action->setChecked(true); action->setShortcut(QKeySequence(tr("1", "Selection mode"))); @@ -175,33 +176,53 @@ void SCgWindow::createToolBar() mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Select] = action; connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode())); + //remove default tooltip + action->setToolTip(""); + //creating custom tooltip + QString path = QString(":/scg/media/video/selection_mode.gif"); + ActionWithVideoTooTip *select_tip = new ActionWithVideoTooTip(tr("Selection mode"), path, mToolBar->widgetForAction(action)); //Pair creation mode - action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar); + action = new QAction(findIcon("tool-pair.png"), tr(""), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("2", "Pair creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Pair] = action; connect(action, SIGNAL(triggered()), this, SLOT(onPairMode())); + //remove default tooltip + action->setToolTip(""); + //creating custom tooltip + path = QString(":/scg/media/video/arc_mode.gif"); + ActionWithVideoTooTip *arc_tip = new ActionWithVideoTooTip("Pair creation mode", path, mToolBar->widgetForAction(action)); //Bus creation mode - action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar); + action = new QAction(findIcon("tool-bus.png"), tr(""), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("3", "Bus creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Bus] = action; connect(action, SIGNAL(triggered()), this, SLOT(onBusMode())); + //remove default tooltip + action->setToolTip(""); + //creating custom tooltip + path = QString(":/scg/media/video/bus_mode.gif"); + ActionWithVideoTooTip *bus_tip = new ActionWithVideoTooTip("Bus creation mode", path, mToolBar->widgetForAction(action)); //Contour creation mode - action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar); + action = new QAction(findIcon("tool-contour.png"), tr(""), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("4", "Contour creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Contour] = action; connect(action, SIGNAL(triggered()), this, SLOT(onContourMode())); + //remove default tooltip + action->setToolTip(""); + //creating custom tooltip + path = QString(":/scg/media/video/contour_mode.gif"); + ActionWithVideoTooTip *contour_tip = new ActionWithVideoTooTip("Contour creation mode", path, mToolBar->widgetForAction(action)); // mToolBar->addSeparator(); //