From 8a7ace463c7bbdff5495906cd56956a80e818bf5 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 7 Oct 2013 14:11:56 +0300 Subject: [PATCH] Tooltip for tools. --HG-- branch : develop --- dialogs/dialogalongline.cpp | 5 +-- dialogs/dialogarc.cpp | 1 + dialogs/dialogbisector.cpp | 3 ++ dialogs/dialogdetail.cpp | 1 + dialogs/dialogendline.cpp | 1 + dialogs/dialogline.cpp | 2 ++ dialogs/dialoglineintersect.cpp | 4 +++ dialogs/dialognormal.cpp | 2 ++ dialogs/dialogpointofcontact.cpp | 3 ++ dialogs/dialogshoulderpoint.cpp | 3 ++ dialogs/dialogspline.cpp | 2 ++ dialogs/dialogsplinepath.cpp | 2 ++ dialogs/dialogtool.h | 1 + mainwindow.cpp | 59 +++++++++++++++++++------------- mainwindow.h | 5 +-- 15 files changed, 67 insertions(+), 27 deletions(-) diff --git a/dialogs/dialogalongline.cpp b/dialogs/dialogalongline.cpp index 87cf627c6..4d522963a 100644 --- a/dialogs/dialogalongline.cpp +++ b/dialogs/dialogalongline.cpp @@ -61,8 +61,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogAlongLine::FormulaChanged); } -DialogAlongLine::~DialogAlongLine() -{ +DialogAlongLine::~DialogAlongLine(){ delete ui; } @@ -90,6 +89,7 @@ void DialogAlongLine::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxFirstPoint->setCurrentIndex(index); number++; + emit ToolTip(tr("Select second point of line")); return; } } @@ -98,6 +98,7 @@ void DialogAlongLine::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxSecondPoint->setCurrentIndex(index); number = 0; + emit ToolTip(""); } if(!isInitialized){ this->show(); diff --git a/dialogs/dialogarc.cpp b/dialogs/dialogarc.cpp index 5c5d864a5..7b4548ef1 100644 --- a/dialogs/dialogarc.cpp +++ b/dialogs/dialogarc.cpp @@ -134,6 +134,7 @@ void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type){ point = data->GetModelingPoint(id); } ChangeCurrentText(ui->comboBoxBasePoint, point.name()); + emit ToolTip(""); this->show(); } } diff --git a/dialogs/dialogbisector.cpp b/dialogs/dialogbisector.cpp index 83520735d..6f6e785ce 100644 --- a/dialogs/dialogbisector.cpp +++ b/dialogs/dialogbisector.cpp @@ -90,6 +90,7 @@ void DialogBisector::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxFirstPoint->setCurrentIndex(index); number++; + emit ToolTip(tr("Select second point of angle")); return; } } @@ -98,6 +99,7 @@ void DialogBisector::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxSecondPoint->setCurrentIndex(index); number++; + emit ToolTip(tr("Select third point of angle")); return; } } @@ -106,6 +108,7 @@ void DialogBisector::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxThirdPoint->setCurrentIndex(index); number = 0; + emit ToolTip(""); } if(!isInitialized){ this->show(); diff --git a/dialogs/dialogdetail.cpp b/dialogs/dialogdetail.cpp index 3d26e18c5..8ccb6adf3 100644 --- a/dialogs/dialogdetail.cpp +++ b/dialogs/dialogdetail.cpp @@ -74,6 +74,7 @@ void DialogDetail::DialogAccepted(){ } details.setName(ui.lineEditNameDetail->text()); emit DialogClosed(QDialog::Accepted); + emit ToolTip(""); } void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode){ diff --git a/dialogs/dialogendline.cpp b/dialogs/dialogendline.cpp index 386f37b09..fc0530c0a 100644 --- a/dialogs/dialogendline.cpp +++ b/dialogs/dialogendline.cpp @@ -101,6 +101,7 @@ void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type){ point = data->GetModelingPoint(id); } ChangeCurrentText(ui->comboBoxBasePoint, point.name()); + emit ToolTip(""); this->show(); } } diff --git a/dialogs/dialogline.cpp b/dialogs/dialogline.cpp index 3c0da94b8..784d6448a 100644 --- a/dialogs/dialogline.cpp +++ b/dialogs/dialogline.cpp @@ -99,6 +99,7 @@ void DialogLine::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxFirstPoint->setCurrentIndex(index); number++; + emit ToolTip(tr("Select second point")); return; } } @@ -107,6 +108,7 @@ void DialogLine::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxSecondPoint->setCurrentIndex(index); number = 0; + emit ToolTip(""); } if(!isInitialized){ this->show(); diff --git a/dialogs/dialoglineintersect.cpp b/dialogs/dialoglineintersect.cpp index 5f18a1a31..3388a331e 100644 --- a/dialogs/dialoglineintersect.cpp +++ b/dialogs/dialoglineintersect.cpp @@ -71,6 +71,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){ ui->comboBoxP1Line1->setCurrentIndex(index); p1Line1 = id; number++; + emit ToolTip(tr("Select second point of first line")); return; } } @@ -80,6 +81,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){ ui->comboBoxP2Line1->setCurrentIndex(index); p2Line1 = id; number++; + emit ToolTip(tr("Select first point of second line")); return; } } @@ -89,6 +91,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){ ui->comboBoxP1Line2->setCurrentIndex(index); p1Line2 = id; number++; + emit ToolTip(tr("Select second point of second line")); return; } } @@ -98,6 +101,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){ ui->comboBoxP2Line2->setCurrentIndex(index); p2Line2 = id; number = 0; + emit ToolTip(""); } if(!isInitialized){ flagPoint = CheckIntersecion(); diff --git a/dialogs/dialognormal.cpp b/dialogs/dialognormal.cpp index 5d52eb5ee..11cb6805d 100644 --- a/dialogs/dialognormal.cpp +++ b/dialogs/dialognormal.cpp @@ -108,6 +108,7 @@ void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxFirstPoint->setCurrentIndex(index); number++; + emit ToolTip(tr("Select second point of line")); return; } } @@ -116,6 +117,7 @@ void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxSecondPoint->setCurrentIndex(index); number = 0; + emit ToolTip(""); } if(!isInitialized){ this->show(); diff --git a/dialogs/dialogpointofcontact.cpp b/dialogs/dialogpointofcontact.cpp index 2f0d85b14..67148bb50 100644 --- a/dialogs/dialogpointofcontact.cpp +++ b/dialogs/dialogpointofcontact.cpp @@ -84,6 +84,7 @@ void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui.comboBoxFirstPoint->setCurrentIndex(index); number++; + emit ToolTip(tr("Select second point of line")); return; } } @@ -92,6 +93,7 @@ void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui.comboBoxSecondPoint->setCurrentIndex(index); number++; + emit ToolTip(tr("Select point of center of arc")); return; } } @@ -100,6 +102,7 @@ void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui.comboBoxCenter->setCurrentIndex(index); number = 0; + emit ToolTip(""); } if(!isInitialized){ this->show(); diff --git a/dialogs/dialogshoulderpoint.cpp b/dialogs/dialogshoulderpoint.cpp index 4197aaebe..28201e968 100644 --- a/dialogs/dialogshoulderpoint.cpp +++ b/dialogs/dialogshoulderpoint.cpp @@ -92,6 +92,7 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxP1Line->setCurrentIndex(index); number++; + emit ToolTip(tr("Select second point of line")); return; } } @@ -100,6 +101,7 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxP2Line->setCurrentIndex(index); number++; + emit ToolTip(tr("Select point of shoulder")); return; } } @@ -108,6 +110,7 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxPShoulder->setCurrentIndex(index); number = 0; + emit ToolTip(""); } if(!isInitialized){ this->show(); diff --git a/dialogs/dialogspline.cpp b/dialogs/dialogspline.cpp index c264d0424..c17c3d385 100644 --- a/dialogs/dialogspline.cpp +++ b/dialogs/dialogspline.cpp @@ -67,6 +67,7 @@ void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxP1->setCurrentIndex(index); number++; + emit ToolTip(tr("Select last point of curve")); return; } } @@ -75,6 +76,7 @@ void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type){ if ( index != -1 ) { // -1 for not found ui->comboBoxP4->setCurrentIndex(index); number = 0; + emit ToolTip(""); index = ui->comboBoxP1->currentIndex(); qint64 p1Id = qvariant_cast(ui->comboBoxP1->itemData(index)); QPointF p1; diff --git a/dialogs/dialogsplinepath.cpp b/dialogs/dialogsplinepath.cpp index aa889010b..0f085895d 100644 --- a/dialogs/dialogsplinepath.cpp +++ b/dialogs/dialogsplinepath.cpp @@ -82,6 +82,7 @@ void DialogSplinePath::ChoosedObject(qint64 id, Scene::Scenes type){ } if(type == Scene::Point){ NewItem(id, 1, 0, 1); + emit ToolTip(tr("Select point of curve path")); this->show(); } } @@ -93,6 +94,7 @@ void DialogSplinePath::DialogAccepted(){ path.append( qvariant_cast(item->data(Qt::UserRole))); } path.setKCurve(ui->doubleSpinBoxKcurve->value()); + emit ToolTip(""); emit DialogClosed(QDialog::Accepted); } diff --git a/dialogs/dialogtool.h b/dialogs/dialogtool.h index b3655df27..630582144 100644 --- a/dialogs/dialogtool.h +++ b/dialogs/dialogtool.h @@ -43,6 +43,7 @@ public: void setIdDetail(const qint64 &value); signals: void DialogClosed(int result); + void ToolTip(const QString &toolTip); public slots: virtual void ChoosedObject(qint64 id, Scene::Scenes type); void NamePointChanged(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 5a023eff3..c2051691b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -65,7 +65,7 @@ MainWindow::MainWindow(QWidget *parent) : QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); policy.setHorizontalStretch(12); view->setSizePolicy(policy); - helpLabel = new QLabel("Створіть новий файл для початку роботи."); + helpLabel = new QLabel(tr("Create new drawing for start working.")); ui->statusBar->addWidget(helpLabel); connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::ActionAroowTool); @@ -204,17 +204,19 @@ void MainWindow::OptionDraw(){ template void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &cursor, - QSharedPointer &dialog, Func closeDialogSlot){ + const QString &toolTip, QSharedPointer &dialog, + Func closeDialogSlot){ if(checked){ CanselTool(); tool = t; QPixmap pixmap(cursor); QCursor cur(pixmap, 2, 3); view->setCursor(cur); - helpLabel->setText("Виберіть точки."); + helpLabel->setText(toolTip); dialog = QSharedPointer(new Dialog(data, mode)); connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject); connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot); + connect(dialog.data(), &Dialog::ToolTip, this, &MainWindow::ShowToolTip); connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList); } else { if(QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())){ @@ -233,8 +235,8 @@ void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool } void MainWindow::ToolEndLine(bool checked){ - SetToolButton(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", dialogEndLine, - &MainWindow::ClosedDialogEndLine); + SetToolButton(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), + dialogEndLine, &MainWindow::ClosedDialogEndLine); } void MainWindow::ClosedDialogEndLine(int result){ @@ -250,8 +252,8 @@ void MainWindow::ClosedDialogEndLine(int result){ } void MainWindow::ToolLine(bool checked){ - SetToolButton(checked, Tool::LineTool, ":/cursor/line_cursor.png", dialogLine, - &MainWindow::ClosedDialogLine); + SetToolButton(checked, Tool::LineTool, ":/cursor/line_cursor.png", tr("Select first point"), + dialogLine, &MainWindow::ClosedDialogLine); } void MainWindow::ClosedDialogLine(int result){ @@ -267,8 +269,8 @@ void MainWindow::ClosedDialogLine(int result){ } void MainWindow::ToolAlongLine(bool checked){ - SetToolButton(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png", dialogAlongLine, - &MainWindow::ClosedDialogAlongLine); + SetToolButton(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png", tr("Select point"), + dialogAlongLine, &MainWindow::ClosedDialogAlongLine); } void MainWindow::ClosedDialogAlongLine(int result){ @@ -284,7 +286,8 @@ void MainWindow::ClosedDialogAlongLine(int result){ } void MainWindow::ToolShoulderPoint(bool checked){ - SetToolButton(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png", dialogShoulderPoint, + SetToolButton(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png", + tr("Select first point of line"), dialogShoulderPoint, &MainWindow::ClosedDialogShoulderPoint); } @@ -302,8 +305,8 @@ void MainWindow::ClosedDialogShoulderPoint(int result){ } void MainWindow::ToolNormal(bool checked){ - SetToolButton(checked, Tool::NormalTool, ":/cursor/normal_cursor.png", dialogNormal, - &MainWindow::ClosedDialogNormal); + SetToolButton(checked, Tool::NormalTool, ":/cursor/normal_cursor.png", + tr("Select first point of line"), dialogNormal, &MainWindow::ClosedDialogNormal); } void MainWindow::ClosedDialogNormal(int result){ @@ -319,8 +322,8 @@ void MainWindow::ClosedDialogNormal(int result){ } void MainWindow::ToolBisector(bool checked){ - SetToolButton(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png", dialogBisector, - &MainWindow::ClosedDialogBisector); + SetToolButton(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png", + tr("Select first point of angle"), dialogBisector, &MainWindow::ClosedDialogBisector); } void MainWindow::ClosedDialogBisector(int result){ @@ -336,7 +339,8 @@ void MainWindow::ClosedDialogBisector(int result){ } void MainWindow::ToolLineIntersect(bool checked){ - SetToolButton(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png", dialogLineIntersect, + SetToolButton(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png", + tr("Select first point of first line"), dialogLineIntersect, &MainWindow::ClosedDialogLineIntersect); } @@ -345,7 +349,8 @@ void MainWindow::ClosedDialogLineIntersect(int result){ if(mode == Draw::Calculation){ VToolLineIntersect::Create(dialogLineIntersect, currentScene, doc, data); } else { - VModelingLineIntersect *point = VModelingLineIntersect::Create(dialogLineIntersect, doc, data); + VModelingLineIntersect *point = VModelingLineIntersect::Create(dialogLineIntersect, doc, + data); AddToolToDetail(point, point->getId(), Tool::LineIntersectTool, dialogLineIntersect->getIdDetail()); } @@ -354,8 +359,8 @@ void MainWindow::ClosedDialogLineIntersect(int result){ } void MainWindow::ToolSpline(bool checked){ - SetToolButton(checked, Tool::SplineTool, ":/cursor/spline_cursor.png", dialogSpline, - &MainWindow::ClosedDialogSpline); + SetToolButton(checked, Tool::SplineTool, ":/cursor/spline_cursor.png", + tr("Select first point curve"), dialogSpline, &MainWindow::ClosedDialogSpline); } void MainWindow::ClosedDialogSpline(int result){ @@ -371,8 +376,8 @@ void MainWindow::ClosedDialogSpline(int result){ } void MainWindow::ToolArc(bool checked){ - SetToolButton(checked, Tool::ArcTool, ":/cursor/arc_cursor.png", dialogArc, - &MainWindow::ClosedDialogArc); + SetToolButton(checked, Tool::ArcTool, ":/cursor/arc_cursor.png", + tr("Select point of center of arc"), dialogArc, &MainWindow::ClosedDialogArc); } void MainWindow::ClosedDialogArc(int result){ @@ -388,7 +393,8 @@ void MainWindow::ClosedDialogArc(int result){ } void MainWindow::ToolSplinePath(bool checked){ - SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png", dialogSplinePath, + SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png", + tr("Select point of curve path"), dialogSplinePath, &MainWindow::ClosedDialogSplinePath); } @@ -405,7 +411,8 @@ void MainWindow::ClosedDialogSplinePath(int result){ } void MainWindow::ToolPointOfContact(bool checked){ - SetToolButton(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", dialogPointOfContact, + SetToolButton(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", + tr("Select first point of line"), dialogPointOfContact, &MainWindow::ClosedDialogPointOfContact); } @@ -430,7 +437,7 @@ void MainWindow::ToolDetail(bool checked){ QPixmap pixmap("://cursor/new_detail_cursor.png"); QCursor cur(pixmap, 2, 3); view->setCursor(cur); - helpLabel->setText("Виберіть точки."); + helpLabel->setText(tr("Select points, arcs, curves and details clockwise.")); dialogDetail = QSharedPointer(new DialogDetail(data, mode)); connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogDetail.data(), &DialogDetail::ChoosedObject); @@ -458,6 +465,10 @@ void MainWindow::AboutQt(){ QMessageBox::aboutQt(this, tr("About Qt")); } +void MainWindow::ShowToolTip(const QString &toolTip){ + helpLabel->setText(toolTip); +} + void MainWindow::tableClosed(){ show(); MinimumScrollBar(); @@ -603,6 +614,7 @@ void MainWindow::CanselTool(){ { case Tool::ArrowTool: ui->actionArrowTool->setChecked(false); + helpLabel->setText(""); break; case Tool::SinglePointTool: //Nothing to do here because we can't create this tool from main window. @@ -1119,4 +1131,5 @@ void MainWindow::OpenPattern(const QString &fileName){ QString title(info.fileName()); title.append("-Valentina"); setWindowTitle(title); + helpLabel->setText(""); } diff --git a/mainwindow.h b/mainwindow.h index eba55383f..3d55ab212 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -94,6 +94,7 @@ public slots: void ClosedDialogDetail(int result); void About(); void AboutQt(); + void ShowToolTip(const QString &toolTip); /** * @brief tableClosed Слот, що виконується при отриманні сигналу закриття вікна укладання *деталей моделі. @@ -149,8 +150,8 @@ private: void SetEnableTool(bool enable); template void SetToolButton(bool checked, Tool::Tools t, const QString &cursor, - QSharedPointer &dialog, - Func closeDialogSlot); + const QString &toolTip,QSharedPointer &dialog, + Func closeDialogSlot); void MinimumScrollBar(); template void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,