Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sources/kbe/kbe.pro
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ MOC_DIR = moc

OTHER_FILES += \
media/stylesheets/projectmanager.qss

DISTFILES += \
media/stylesheets/tooltipstyle.css
1 change: 1 addition & 0 deletions sources/kbe/kbe.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<file>media/icons/pm-collapse.png</file>
<file>media/icons/pm-expand.png</file>
<file>media/icons/pm-add.png</file>
<file>media/stylesheets/tooltipstyle.css</file>
</qresource>
</RCC>
6 changes: 6 additions & 0 deletions sources/kbe/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 6 additions & 0 deletions sources/kbe/media/stylesheets/tooltipstyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
QToolTip {
background-color: black;
color: white;
opacity: 200%;
padding: 3px;
}
Binary file added sources/plugins/scg/media/video/arc_mode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sources/plugins/scg/media/video/bus_mode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sources/plugins/scg/media/video/contour_mode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions sources/plugins/scg/scg.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ win32 {
}

HEADERS += \
scgactionwithvideotooltip.h \
scgwindow.h \
scgview.h \
scgtemplateobjectbuilder.h \
Expand Down Expand Up @@ -98,6 +99,7 @@ HEADERS += \
scgtypedialog.h

SOURCES += \
scgactionwithvideotooltip.cpp \
scgwindow.cpp \
scgview.cpp \
scgtemplateobjectbuilder.cpp \
Expand Down
4 changes: 4 additions & 0 deletions sources/plugins/scg/scg.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@
<file>media/icons/tool-select-subgraph.png</file>
<file>media/translations/scg_en_EN.qm</file>
<file>media/translations/scg_ru_RU.qm</file>
<file>media/video/arc_mode.gif</file>
<file>media/video/bus_mode.gif</file>
<file>media/video/contour_mode.gif</file>
<file>media/video/selection_mode.gif</file>
</qresource>
</RCC>
57 changes: 57 additions & 0 deletions sources/plugins/scg/scgactionwithvideotooltip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "scgactionwithvideotooltip.h"

#include <QApplication>
#include <QToolTip>
#include <QLabel>
#include <QDebug>
#include <QVBoxLayout>
#include <unistd.h>


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);
}
29 changes: 29 additions & 0 deletions sources/plugins/scg/scgactionwithvideotooltip.h
Original file line number Diff line number Diff line change
@@ -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 <QEvent>
#include <QToolTip>
#include <QAction>
#include <QString>
#include <QMovie>
#include <QLabel>

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;

};
29 changes: 25 additions & 4 deletions sources/plugins/scg/scgwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "scgtemplateobjectbuilder.h"
#include "config.h"
#include "scgundoview.h"
#include "scgactionwithvideotooltip.h"


const QString SCgWindow::SupportedPasteMimeType = "text/KBE-gwf";
Expand Down Expand Up @@ -167,41 +168,61 @@ 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")));
group->addAction(action);
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();
//
Expand Down