~daggerstab/stellarium/oculars-gui-improvement

« back to all changes in this revision

Viewing changes to plugins/AngleMeasure/src/AngleMeasure.cpp

  • Committer: Bogdan Marinov
  • Date: 2011-11-10 23:39:52 UTC
  • mfrom: (4948.1.52 stellarium)
  • Revision ID: bogdan.marinov84@gmail.com-20111110233952-d44bk1q756mybt1k
merged in trunk at revision 5000

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
        StelPluginInfo info;
56
56
        info.id = "AngleMeasure";
57
 
        info.displayedName = q_("Angle Measure");
 
57
        info.displayedName = N_("Angle Measure");
58
58
        info.authors = "Matthew Gates";
59
59
        info.contact = "http://porpoisehead.net/";
60
 
        info.description = q_("Provides an angle measurement tool");
 
60
        info.description = N_("Provides an angle measurement tool");
61
61
        return info;
62
62
}
63
63
 
115
115
        perp2StartPoint.set(0.,0.,0.);
116
116
        perp2EndPoint.set(0.,0.,0.);
117
117
 
118
 
        // create action for enable/disable & hook up signals
119
 
        StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
 
118
        StelApp& app = StelApp::getInstance();
 
119
 
 
120
        // Create action for enable/disable & hook up signals
 
121
        StelGui* gui = dynamic_cast<StelGui*>(app.getGui());
120
122
        Q_ASSERT(gui);
121
 
        gui->addGuiActions("actionShow_Angle_Measure", N_("Angle measure"), "Ctrl+A", N_("Plugin Key Bindings"), true, false);
122
 
        gui->getGuiActions("actionShow_Angle_Measure")->setChecked(flagShowAngleMeasure);
123
 
        connect(gui->getGuiActions("actionShow_Angle_Measure"), SIGNAL(toggled(bool)), this, SLOT(enableAngleMeasure(bool)));
 
123
        QAction* action = gui->addGuiActions("actionShow_Angle_Measure",
 
124
                                             N_("Angle measure"),
 
125
                                             "Ctrl+A",
 
126
                                             N_("Plugin Key Bindings"),
 
127
                                             true, false);
 
128
        action->setChecked(flagShowAngleMeasure);
 
129
        connect(action, SIGNAL(toggled(bool)), this, SLOT(enableAngleMeasure(bool)));
 
130
 
 
131
        // Initialize the message strings and make sure they are translated when
 
132
        // the language changes.
 
133
        updateMessageText();
 
134
        connect(&app, SIGNAL(languageChanged()), this, SLOT(updateMessageText()));
124
135
 
125
136
        // Add a toolbar button
126
137
        try
179
190
        if (messageFader.getInterstate() > 0.000001f)
180
191
        {
181
192
                painter.setColor(textColor[0], textColor[1], textColor[2], messageFader.getInterstate());
182
 
                painter.drawText(83, 120, "Angle Tool Enabled - left drag to measure, left click to clear");
183
 
                painter.drawText(83, 95,  "right click to change end point only");
 
193
                int x = 83;
 
194
                int y = 120;
 
195
                int ls = painter.getFontMetrics().lineSpacing();
 
196
                painter.drawText(x, y, messageEnabled);
 
197
                y -= ls;
 
198
                painter.drawText(x, y, messageLeftButton);
 
199
                y -= ls;
 
200
                painter.drawText(x, y, messageRightButton);
184
201
        }
185
202
}
186
203
 
280
297
        messageFader = b;
281
298
        if (b)
282
299
        {
283
 
                qDebug() << "AngleMeasure::enableAngleMeasure starting timer";
 
300
                //qDebug() << "AngleMeasure::enableAngleMeasure starting timer";
284
301
                messageTimer->start();
285
302
        }
286
303
}
287
304
 
 
305
void AngleMeasure::updateMessageText()
 
306
{
 
307
        // TRANSLATORS: instructions for using the AngleMeasure plugin.
 
308
        messageEnabled = q_("The Angle Measure is enabled:");
 
309
        // TRANSLATORS: instructions for using the AngleMeasure plugin.
 
310
        messageLeftButton = q_("Drag with the left button to measure, left-click to clear.");
 
311
        // TRANSLATORS: instructions for using the AngleMeasure plugin.
 
312
        messageRightButton = q_("Right-clicking changes the end point only.");
 
313
}
 
314
 
288
315
void AngleMeasure::clearMessage()
289
316
{
290
 
        qDebug() << "AngleMeasure::clearMessage";
 
317
        //qDebug() << "AngleMeasure::clearMessage";
291
318
        messageFader = false;
292
319
}
293