Changeset View
Changeset View
Standalone View
Standalone View
src/kalgebra.cpp
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 106 | { | |||
---|---|---|---|---|---|
121 | g_menu->addAction(KStandardAction::quit(this, SLOT(close()), this)); | 121 | g_menu->addAction(KStandardAction::quit(this, SLOT(close()), this)); | ||
122 | 122 | | |||
123 | QToolButton* fullScreenButton = new QToolButton(this); | 123 | QToolButton* fullScreenButton = new QToolButton(this); | ||
124 | fullScreenButton->setDefaultAction(fullScreenAction); | 124 | fullScreenButton->setDefaultAction(fullScreenAction); | ||
125 | m_tabs->setCornerWidget(fullScreenButton); | 125 | m_tabs->setCornerWidget(fullScreenButton); | ||
126 | 126 | | |||
127 | m_status = new QLabel(this); | 127 | m_status = new QLabel(this); | ||
128 | statusBar()->insertWidget(0, m_status); | 128 | statusBar()->insertWidget(0, m_status); | ||
129 | menuBar()->addAction(QStringLiteral("|"))->setEnabled(false); | | |||
130 | 129 | | |||
131 | ///////Console | 130 | ///////Console | ||
132 | QWidget *console = new QWidget(m_tabs); | 131 | QWidget *console = new QWidget(m_tabs); | ||
133 | QVBoxLayout *c_layo = new QVBoxLayout(console); | 132 | QVBoxLayout *c_layo = new QVBoxLayout(console); | ||
134 | c_results = new ConsoleHtml(console); | 133 | c_results = new ConsoleHtml(console); | ||
135 | c_results->setFocusPolicy(Qt::NoFocus); | 134 | c_results->setFocusPolicy(Qt::NoFocus); | ||
136 | c_dock_vars = new QDockWidget(i18n("Variables"), this); | 135 | c_dock_vars = new QDockWidget(i18n("Variables"), this); | ||
137 | c_dock_vars->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable); | 136 | c_dock_vars->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable); | ||
Show All 12 Lines | |||||
150 | c_exp = new Analitza::ExpressionEdit(console); | 149 | c_exp = new Analitza::ExpressionEdit(console); | ||
151 | c_exp->setAnalitza(c_results->analitza()); | 150 | c_exp->setAnalitza(c_results->analitza()); | ||
152 | c_exp->setExamples(QStringList() << QStringLiteral("square:=x->x**2") << QStringLiteral("fib:=n->piecewise { eq(n,0)?0, eq(n,1)?1, ?fib(n-1)+fib(n-2) }")); | 151 | c_exp->setExamples(QStringList() << QStringLiteral("square:=x->x**2") << QStringLiteral("fib:=n->piecewise { eq(n,0)?0, eq(n,1)?1, ?fib(n-1)+fib(n-2) }")); | ||
153 | c_dock_vars->setWidget(c_variables); | 152 | c_dock_vars->setWidget(c_variables); | ||
154 | 153 | | |||
155 | m_tabs->addTab(console, i18n("&Calculator")); | 154 | m_tabs->addTab(console, i18n("&Calculator")); | ||
156 | console->setLayout(c_layo); | 155 | console->setLayout(c_layo); | ||
157 | c_layo->addWidget(c_results); | 156 | c_layo->addWidget(c_results); | ||
158 | c_layo->addWidget(c_exp); | | |||
159 | 157 | | |||
158 | auto layout = new QBoxLayout(QBoxLayout::RightToLeft); | ||||
159 | | ||||
160 | QPushButton* enter = new QPushButton(i18n("&Enter"), this); | ||||
161 | QPushButton* clear = new QPushButton(i18n("&Clear"), this); | ||||
tcanabrava: please use the translation functions here. it's' the i18n call. | |||||
162 | | ||||
163 | layout->addWidget(clear); | ||||
164 | layout->addWidget(enter); | ||||
165 | layout->addWidget(c_exp); | ||||
166 | | ||||
167 | c_layo->addLayout(layout); | ||||
168 | | ||||
169 | connect(clear, &QPushButton::clicked, c_results, &ConsoleHtml::clear); | ||||
170 | connect(enter, &QPushButton::clicked, this, &KAlgebra::operate); | ||||
160 | connect(c_exp, &Analitza::ExpressionEdit::returnPressed, this, &KAlgebra::operate); | 171 | connect(c_exp, &Analitza::ExpressionEdit::returnPressed, this, &KAlgebra::operate); | ||
161 | connect(c_results, &ConsoleHtml::status, this, &KAlgebra::changeStatusBar); | 172 | connect(c_results, &ConsoleHtml::status, this, &KAlgebra::changeStatusBar); | ||
162 | connect(c_results, &ConsoleHtml::changed, this, &KAlgebra::updateInformation); | 173 | connect(c_results, &ConsoleHtml::changed, this, &KAlgebra::updateInformation); | ||
163 | connect(c_results, SIGNAL(changed()), c_exp, SLOT(updateCompleter())); | 174 | connect(c_results, SIGNAL(changed()), c_exp, SLOT(updateCompleter())); | ||
164 | connect(c_results, SIGNAL(paste(QString)), c_exp, SLOT(insertText(QString))); | 175 | connect(c_results, SIGNAL(paste(QString)), c_exp, SLOT(insertText(QString))); | ||
165 | connect(c_variables, &QAbstractItemView::clicked, this, &KAlgebra::edit_var); | 176 | connect(c_variables, &QAbstractItemView::clicked, this, &KAlgebra::edit_var); | ||
166 | ////////menu | | |||
167 | c_menu = menuBar()->addMenu(i18n("C&alculator")); | | |||
168 | | ||||
169 | c_menu->addAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("@item:inmenu", "&Load Script..."), | | |||
170 | this, SLOT(loadScript()), Qt::CTRL+Qt::Key_L); | | |||
171 | c_recentScripts=new KRecentFilesAction(QIcon::fromTheme(QStringLiteral("document-open-recent")), i18n("Recent Scripts"), this); | | |||
172 | connect(c_recentScripts, SIGNAL(urlSelected(QUrl)), this, SLOT(loadScript(QUrl))); | | |||
173 | c_menu->addAction(c_recentScripts); | | |||
174 | | ||||
175 | c_menu->addAction(QIcon::fromTheme(QStringLiteral("document-save")), i18nc("@item:inmenu", "&Save Script..."), | | |||
176 | this, SLOT(saveScript()), Qt::CTRL+Qt::Key_G); | | |||
177 | c_menu->addAction(QIcon::fromTheme(QStringLiteral("document-save")), i18nc("@item:inmenu", "&Export Log..."), | | |||
178 | this, SLOT(saveLog()), QKeySequence::Save); | | |||
179 | c_menu->addSeparator()->setText(i18n("Execution Mode")); | | |||
180 | QActionGroup *execGroup = new QActionGroup(c_menu); | | |||
181 | QAction* calc = c_menu->addAction(i18nc("@item:inmenu", "Calculate"), this, SLOT(consoleCalculate())); | | |||
182 | QAction* eval = c_menu->addAction(i18nc("@item:inmenu", "Evaluate"), this, SLOT(consoleEvaluate())); | | |||
183 | | ||||
184 | calc->setCheckable(true); | | |||
185 | eval->setCheckable(true); | | |||
186 | eval->setChecked(true); | | |||
187 | execGroup->addAction(calc); | | |||
188 | execGroup->addAction(eval); | | |||
189 | c_menu->addSeparator(); | | |||
190 | c_menu->addAction(KStandardAction::clear(c_results, SLOT(clear()), this)); | | |||
191 | initializeRecentScripts(); | | |||
192 | //////////// | | |||
193 | //////EOConsola | | |||
194 | 177 | | |||
195 | //////2D Graph | 178 | //////2D Graph | ||
196 | b_funcsModel=new Analitza::PlotsModel(this); | 179 | b_funcsModel=new Analitza::PlotsModel(this); | ||
197 | 180 | | |||
198 | m_graph2d = new Analitza::PlotsView2D(m_tabs); | 181 | m_graph2d = new Analitza::PlotsView2D(m_tabs); | ||
199 | m_graph2d->setTicksShown(0); | 182 | m_graph2d->setTicksShown(0); | ||
200 | m_graph2d->setModel(b_funcsModel); | 183 | m_graph2d->setModel(b_funcsModel); | ||
201 | 184 | | |||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
243 | connect(b_varsModel, &QAbstractItemModel::dataChanged, this, &KAlgebra::valueChanged); | 226 | connect(b_varsModel, &QAbstractItemModel::dataChanged, this, &KAlgebra::valueChanged); | ||
244 | connect(b_funcs, &QAbstractItemView::doubleClicked, this, &KAlgebra::edit_func); | 227 | connect(b_funcs, &QAbstractItemView::doubleClicked, this, &KAlgebra::edit_func); | ||
245 | connect(b_tools, &QTabWidget::currentChanged, this, &KAlgebra::functools); | 228 | connect(b_tools, &QTabWidget::currentChanged, this, &KAlgebra::functools); | ||
246 | connect(m_graph2d, &Analitza::PlotsView2D::status, this, &KAlgebra::changeStatusBar); | 229 | connect(m_graph2d, &Analitza::PlotsView2D::status, this, &KAlgebra::changeStatusBar); | ||
247 | connect(m_graph2d, SIGNAL(viewportChanged(QRectF)), b_viewport, SLOT(setViewport(QRectF))); | 230 | connect(m_graph2d, SIGNAL(viewportChanged(QRectF)), b_viewport, SLOT(setViewport(QRectF))); | ||
248 | connect(b_viewport, SIGNAL(viewportChange(QRectF)), m_graph2d, SLOT(changeViewport(QRectF))); | 231 | connect(b_viewport, SIGNAL(viewportChange(QRectF)), m_graph2d, SLOT(changeViewport(QRectF))); | ||
249 | connect(b_varsView, &QWidget::customContextMenuRequested, this, &KAlgebra::varsContextMenu); | 232 | connect(b_varsView, &QWidget::customContextMenuRequested, this, &KAlgebra::varsContextMenu); | ||
250 | 233 | | |||
251 | ////////menu | | |||
252 | b_menu = menuBar()->addMenu(i18n("2&D Graph")); | | |||
253 | QAction* b_actions[6]; | | |||
254 | b_actions[0] = b_menu->addAction(i18n("&Grid"), this, SLOT(toggleSquares())); | | |||
255 | b_actions[1] = b_menu->addAction(i18n("&Keep Aspect Ratio"), this, SLOT(toggleKeepAspect())); | | |||
256 | b_menu->addAction(KStandardAction::save(this, SLOT(saveGraph()), this)); | | |||
257 | b_menu->addSeparator(); | | |||
258 | b_menu->addAction(KStandardAction::zoomIn(m_graph2d, SLOT(zoomIn()), this)); | | |||
259 | b_menu->addAction(KStandardAction::zoomOut(m_graph2d, SLOT(zoomOut()), this)); | | |||
260 | QAction* ac=KStandardAction::actualSize(m_graph2d, SLOT(resetViewport()), this); | | |||
261 | ac->setShortcut(Qt::ControlModifier + Qt::Key_0); | | |||
262 | b_menu->addAction(ac); | | |||
263 | b_menu->addSeparator()->setText(i18n("Resolution")); | | |||
264 | b_actions[2] = b_menu->addAction(i18nc("@item:inmenu", "Poor"), this, SLOT(set_res_low())); | | |||
265 | b_actions[3] = b_menu->addAction(i18nc("@item:inmenu", "Normal"), this, SLOT(set_res_std())); | | |||
266 | b_actions[4] = b_menu->addAction(i18nc("@item:inmenu", "Fine"), this, SLOT(set_res_fine())); | | |||
267 | b_actions[5] = b_menu->addAction(i18nc("@item:inmenu", "Very Fine"), this, SLOT(set_res_vfine())); | | |||
268 | m_graph2d->setContextMenuPolicy(Qt::ActionsContextMenu); | | |||
269 | m_graph2d->addActions(b_menu->actions()); | | |||
270 | | ||||
271 | QActionGroup *res = new QActionGroup(b_menu); | | |||
272 | res->addAction(b_actions[2]); | | |||
273 | res->addAction(b_actions[3]); | | |||
274 | res->addAction(b_actions[4]); | | |||
275 | res->addAction(b_actions[5]); | | |||
276 | | ||||
277 | b_actions[0]->setCheckable(true); | | |||
278 | b_actions[0]->setChecked(true); | | |||
279 | b_actions[1]->setCheckable(true); | | |||
280 | b_actions[1]->setChecked(true); | | |||
281 | b_actions[2]->setCheckable(true); | | |||
282 | b_actions[3]->setCheckable(true); | | |||
283 | b_actions[3]->setChecked(true); | | |||
284 | b_actions[4]->setCheckable(true); | | |||
285 | b_actions[5]->setCheckable(true); | | |||
286 | set_res_std(); | | |||
287 | //////EO2D Graph | | |||
288 | | ||||
289 | /////3DGraph | 234 | /////3DGraph | ||
290 | QWidget *tridim = new QWidget(m_tabs); | 235 | QWidget *tridim = new QWidget(m_tabs); | ||
291 | QVBoxLayout *t_layo = new QVBoxLayout(tridim); | 236 | QVBoxLayout *t_layo = new QVBoxLayout(tridim); | ||
292 | t_exp = new Analitza::ExpressionEdit(tridim); | 237 | t_exp = new Analitza::ExpressionEdit(tridim); | ||
293 | t_exp->setExamples(Analitza::PlotsFactory::self()->examples(Analitza::Dim3D)); | 238 | t_exp->setExamples(Analitza::PlotsFactory::self()->examples(Analitza::Dim3D)); | ||
294 | t_exp->setAns(QStringLiteral("x")); | 239 | t_exp->setAns(QStringLiteral("x")); | ||
295 | t_model3d = new Analitza::PlotsModel(this); | 240 | t_model3d = new Analitza::PlotsModel(this); | ||
296 | m_graph3d = new Analitza::PlotsView3DES(tridim); | 241 | m_graph3d = new Analitza::PlotsView3DES(tridim); | ||
297 | m_graph3d->setModel(t_model3d); | 242 | m_graph3d->setModel(t_model3d); | ||
298 | m_graph3d->setUseSimpleRotation(true); | 243 | m_graph3d->setUseSimpleRotation(true); | ||
299 | 244 | | |||
300 | tridim->setLayout(t_layo); | 245 | tridim->setLayout(t_layo); | ||
301 | m_tabs->addTab(tridim, i18n("&3D Graph")); | 246 | m_tabs->addTab(tridim, i18n("&3D Graph")); | ||
302 | t_layo->addWidget(m_graph3d); | 247 | t_layo->addWidget(m_graph3d); | ||
303 | t_layo->addWidget(t_exp); | 248 | t_layo->addWidget(t_exp); | ||
304 | 249 | | |||
305 | connect(t_exp, &Analitza::ExpressionEdit::returnPressed, this, &KAlgebra::new_func3d); | 250 | connect(t_exp, &Analitza::ExpressionEdit::returnPressed, this, &KAlgebra::new_func3d); | ||
306 | c_results->addOptionsObserver(new Add3DOption(this)); | 251 | c_results->addOptionsObserver(new Add3DOption(this)); | ||
307 | 252 | | |||
308 | ////////menu | | |||
309 | t_menu = menuBar()->addMenu(i18n("3D &Graph")); | | |||
310 | QAction* t_actions[5]; | | |||
311 | t_menu->addAction(KStandardAction::save(this, SLOT(save3DGraph()), this)); | | |||
312 | t_menu->addAction(QIcon::fromTheme(QStringLiteral("zoom-original")), i18n("&Reset View"), m_graph3d, [this]() { m_graph3d->resetViewport(); }); | | |||
313 | t_menu->addSeparator(); | | |||
314 | t_actions[2] = t_menu->addAction(i18n("Dots"), this, SLOT(set_dots())); | | |||
315 | t_actions[3] = t_menu->addAction(i18n("Lines"), this, SLOT(set_lines())); | | |||
316 | t_actions[4] = t_menu->addAction(i18n("Solid"), this, SLOT(set_solid())); | | |||
317 | | ||||
318 | QActionGroup *t_type = new QActionGroup(t_menu); | | |||
319 | t_type->addAction(t_actions[2]); | | |||
320 | t_type->addAction(t_actions[3]); | | |||
321 | t_type->addAction(t_actions[4]); | | |||
322 | | ||||
323 | t_actions[2]->setCheckable(true); | | |||
324 | t_actions[3]->setCheckable(true); | | |||
325 | t_actions[4]->setCheckable(true); | | |||
326 | t_actions[4]->setChecked(true); | | |||
327 | | ||||
328 | //////////// | | |||
329 | //////EO3D Graph | | |||
330 | menuBar()->addAction(QStringLiteral("|"))->setEnabled(false); | | |||
331 | | ||||
332 | //Dictionary tab | 253 | //Dictionary tab | ||
333 | d_dock = new QDockWidget(i18n("Operations"), this); | 254 | d_dock = new QDockWidget(i18n("Operations"), this); | ||
334 | d_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); | 255 | d_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); | ||
335 | addDockWidget(Qt::RightDockWidgetArea, d_dock); | 256 | addDockWidget(Qt::RightDockWidgetArea, d_dock); | ||
336 | Dictionary *dic = new Dictionary(m_tabs); | 257 | Dictionary *dic = new Dictionary(m_tabs); | ||
337 | m_tabs->addTab(dic, i18n("&Dictionary")); | 258 | m_tabs->addTab(dic, i18n("&Dictionary")); | ||
338 | 259 | | |||
339 | QWidget *w=new QWidget; | 260 | QWidget *w=new QWidget; | ||
340 | QLayout *leftLayo=new QVBoxLayout(w); | 261 | QLayout *leftLayo=new QVBoxLayout(w); | ||
341 | d_filter=new QLineEdit(w); | 262 | d_filter=new QLineEdit(w); | ||
342 | d_filter->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed)); | 263 | d_filter->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed)); | ||
343 | connect(d_filter, &QLineEdit::textChanged, dic, &Dictionary::setFilter); | 264 | connect(d_filter, &QLineEdit::textChanged, dic, &Dictionary::setFilter); | ||
344 | connect(d_filter, &QLineEdit::textChanged, this, &KAlgebra::dictionaryFilterChanged); | 265 | connect(d_filter, &QLineEdit::textChanged, this, &KAlgebra::dictionaryFilterChanged); | ||
345 | d_list = new QListView(w); | 266 | d_list = new QListView(w); | ||
346 | d_list->setModel(dic->model()); | 267 | d_list->setModel(dic->model()); | ||
347 | d_list->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); | 268 | d_list->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); | ||
348 | leftLayo->addWidget(new QLabel(i18n("Look for:"), d_dock)); | 269 | leftLayo->addWidget(new QLabel(i18n("Look for:"), d_dock)); | ||
349 | leftLayo->addWidget(d_filter); | 270 | leftLayo->addWidget(d_filter); | ||
350 | leftLayo->addWidget(d_list); | 271 | leftLayo->addWidget(d_list); | ||
351 | d_dock->setWidget(w); | 272 | d_dock->setWidget(w); | ||
352 | 273 | | |||
353 | connect(d_list->selectionModel(), &QItemSelectionModel::currentChanged, | 274 | connect(d_list->selectionModel(), &QItemSelectionModel::currentChanged, | ||
354 | dic, &Dictionary::activated); | 275 | dic, &Dictionary::activated); | ||
355 | 276 | | |||
277 | //files | ||||
278 | QMenu* fileMenu = new QMenu(); | ||||
279 | fileMenu = menuBar()->addMenu(tr("&File")); | ||||
280 | | ||||
281 | fileMenu->addAction(KStandardAction::save(this, SLOT(smartSaveGraph()), this)); | ||||
282 | | ||||
283 | fileMenu->addSeparator()->setText(i18n("Calculator")); | ||||
284 | fileMenu->addAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("@item:inmenu", "&Load Script..."), | ||||
285 | this, SLOT(loadScript()), Qt::CTRL+Qt::Key_L); | ||||
286 | c_recentScripts=new KRecentFilesAction(QIcon::fromTheme(QStringLiteral("document-open-recent")), i18n("Recent Scripts"), this); | ||||
287 | connect(c_recentScripts, SIGNAL(urlSelected(QUrl)), this, SLOT(loadScript(QUrl))); | ||||
288 | fileMenu->addAction(c_recentScripts); | ||||
289 | | ||||
290 | fileMenu->addAction(QIcon::fromTheme(QStringLiteral("document-save")), i18nc("@item:inmenu", "&Save Script..."), | ||||
291 | this, SLOT(saveScript()), Qt::CTRL+Qt::Key_G); | ||||
292 | | ||||
293 | //settings | ||||
294 | QMenu* settingsMenu = new QMenu(); | ||||
295 | settingsMenu = menuBar()->addMenu(tr("&Settings")); | ||||
296 | settingsMenu->addAction(i18n("Reset View"), this, SLOT(resetView()),Qt::CTRL+Qt::Key_R); | ||||
297 | | ||||
298 | QActionGroup *execGroup = new QActionGroup(settingsMenu); | ||||
299 | | ||||
300 | settingsMenu->addSeparator()->setText(i18n("Calculator")); | ||||
301 | QAction* calc = settingsMenu->addAction(i18nc("@item:inmenu", "Calculate"), this, SLOT(consoleCalculate())); | ||||
302 | QAction* eval = settingsMenu->addAction(i18nc("@item:inmenu", "Evaluate"), this, SLOT(consoleEvaluate())); | ||||
303 | | ||||
304 | calc->setCheckable(true); | ||||
305 | eval->setCheckable(true); | ||||
306 | eval->setChecked(true); | ||||
307 | execGroup->addAction(calc); | ||||
308 | execGroup->addAction(eval); | ||||
309 | | ||||
310 | settingsMenu->addSeparator()->setText(i18n("2D Graph")); | ||||
311 | | ||||
312 | QAction* kactions[6]; | ||||
313 | kactions[0] = settingsMenu->addAction(i18n("&Grid"), this, SLOT(toggleSquares())); | ||||
314 | kactions[1] = settingsMenu->addAction(i18n("&Keep Aspect Ratio"), this, SLOT(toggleKeepAspect())); | ||||
315 | settingsMenu->addSeparator()->setText(i18n("Resolution")); | ||||
316 | kactions[2] = settingsMenu->addAction(i18nc("@item:inmenu", "Poor"), this, SLOT(set_res_low())); | ||||
317 | kactions[3] = settingsMenu->addAction(i18nc("@item:inmenu", "Normal"), this, SLOT(set_res_std())); | ||||
318 | kactions[4] = settingsMenu->addAction(i18nc("@item:inmenu", "Fine"), this, SLOT(set_res_fine())); | ||||
319 | kactions[5] = settingsMenu->addAction(i18nc("@item:inmenu", "Very Fine"), this, SLOT(set_res_vfine())); | ||||
320 | | ||||
321 | QActionGroup *resolution = new QActionGroup(settingsMenu); | ||||
322 | | ||||
323 | resolution->addAction(kactions[2]); | ||||
324 | resolution->addAction(kactions[3]); | ||||
325 | resolution->addAction(kactions[4]); | ||||
326 | resolution->addAction(kactions[5]); | ||||
327 | | ||||
328 | kactions[0]->setCheckable(true); | ||||
329 | kactions[0]->setChecked(true); | ||||
330 | kactions[1]->setCheckable(true); | ||||
331 | kactions[1]->setChecked(true); | ||||
332 | kactions[2]->setCheckable(true); | ||||
333 | kactions[3]->setCheckable(true); | ||||
334 | kactions[3]->setChecked(true); | ||||
335 | kactions[4]->setCheckable(true); | ||||
336 | kactions[5]->setCheckable(true); | ||||
337 | set_res_std(); | ||||
338 | | ||||
339 | settingsMenu->addSeparator()->setText(i18n("3D Graph")); | ||||
340 | | ||||
341 | QAction* jactions[3]; | ||||
342 | | ||||
343 | jactions[0] = settingsMenu->addAction(i18n("Dots"), this, SLOT(set_dots())); | ||||
344 | jactions[1] = settingsMenu->addAction(i18n("Lines"), this, SLOT(set_lines())); | ||||
345 | jactions[2] = settingsMenu->addAction(i18n("Solid"), this, SLOT(set_solid())); | ||||
346 | | ||||
347 | jactions[2]->setCheckable(true); | ||||
348 | jactions[2]->setChecked(true); | ||||
349 | | ||||
350 | QActionGroup *plotType = new QActionGroup(settingsMenu); | ||||
351 | plotType->addAction(jactions[0]); | ||||
352 | plotType->addAction(jactions[1]); | ||||
353 | plotType->addAction(jactions[2]); | ||||
354 | | ||||
355 | jactions[0]->setCheckable(true); | ||||
356 | jactions[1]->setCheckable(true); | ||||
357 | jactions[2]->setCheckable(true); | ||||
358 | | ||||
356 | //EODictionary | 359 | //EODictionary | ||
357 | //Ego's reminder | 360 | //Ego's reminder | ||
358 | KHelpMenu* help = new KHelpMenu(this); | 361 | KHelpMenu* help = new KHelpMenu(this); | ||
359 | menuBar()->addMenu(help->menu()); | 362 | menuBar()->addMenu(help->menu()); | ||
360 | 363 | | |||
361 | #pragma message("TODO: Port to PlotsModel") | 364 | #pragma message("TODO: Port to PlotsModel") | ||
362 | // connect(b_funcsModel, SIGNAL(functionModified(QString,Analitza::Expression)), | 365 | // connect(b_funcsModel, SIGNAL(functionModified(QString,Analitza::Expression)), | ||
363 | // c_results, SLOT(modifyVariable(QString,Analitza::Expression))); | 366 | // c_results, SLOT(modifyVariable(QString,Analitza::Expression))); | ||
364 | // connect(b_funcsModel, SIGNAL(functionRemoved(QString)), | 367 | // connect(b_funcsModel, SIGNAL(functionRemoved(QString)), | ||
365 | // c_results, SLOT(removeVariable(QString))); | 368 | // c_results, SLOT(removeVariable(QString))); | ||
366 | 369 | | |||
370 | | ||||
367 | connect(m_tabs, &QTabWidget::currentChanged, this, &KAlgebra::tabChanged); | 371 | connect(m_tabs, &QTabWidget::currentChanged, this, &KAlgebra::tabChanged); | ||
368 | tabChanged(0); | 372 | tabChanged(0); | ||
369 | } | 373 | } | ||
370 | 374 | | |||
371 | KAlgebra::~KAlgebra() | 375 | KAlgebra::~KAlgebra() | ||
372 | { | 376 | { | ||
373 | KConfig conf(QStringLiteral("kalgebrarc")); | 377 | KConfig conf(QStringLiteral("kalgebrarc")); | ||
374 | KConfigGroup config(&conf, "Default"); | 378 | KConfigGroup config(&conf, "Default"); | ||
375 | QStringList urls; | 379 | QStringList urls; | ||
376 | foreach(const QUrl& url, c_recentScripts->urls()) | 380 | foreach(const QUrl& url, c_recentScripts->urls()) | ||
377 | urls += url.toDisplayString(); | 381 | urls += url.toDisplayString(); | ||
378 | 382 | | |||
379 | config.writeEntry("recent", urls); | 383 | config.writeEntry("recent", urls); | ||
380 | } | 384 | } | ||
381 | 385 | | |||
386 | void KAlgebra::resetView(){ | ||||
387 | switch(m_tabs->currentIndex()){ | ||||
388 | case 1: | ||||
389 | m_graph2d->resetViewport(); | ||||
390 | break; | ||||
391 | case 2: | ||||
392 | m_graph3d->resetViewport(); | ||||
393 | break; | ||||
394 | } | ||||
395 | } | ||||
396 | | ||||
382 | void KAlgebra::initializeRecentScripts() | 397 | void KAlgebra::initializeRecentScripts() | ||
383 | { | 398 | { | ||
384 | KConfig conf(QStringLiteral("kalgebrarc")); | 399 | KConfig conf(QStringLiteral("kalgebrarc")); | ||
385 | KConfigGroup config(&conf, "Default"); | 400 | KConfigGroup config(&conf, "Default"); | ||
386 | 401 | | |||
387 | QStringList urls=config.readEntry("recent", QStringList()); | 402 | QStringList urls=config.readEntry("recent", QStringList()); | ||
388 | foreach(const QString& url, urls) { | 403 | foreach(const QString& url, urls) { | ||
389 | c_recentScripts->addUrl(QUrl(url)); | 404 | c_recentScripts->addUrl(QUrl(url)); | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
488 | } | 503 | } | ||
489 | 504 | | |||
490 | void KAlgebra::changeStatusBar(const QString& msg) | 505 | void KAlgebra::changeStatusBar(const QString& msg) | ||
491 | { | 506 | { | ||
492 | // statusBar()->showMessage(msg); | 507 | // statusBar()->showMessage(msg); | ||
493 | m_status->setText(msg); | 508 | m_status->setText(msg); | ||
494 | } | 509 | } | ||
495 | 510 | | |||
511 | void KAlgebra::smartSaveGraph(){ | ||||
512 | switch (m_tabs->currentIndex()){ | ||||
513 | case 0: | ||||
514 | saveLog(); | ||||
515 | break; | ||||
516 | case 1: | ||||
tcanabrava: remove this empty space | |||||
517 | saveGraph(); | ||||
518 | break; | ||||
519 | case 2: | ||||
520 | save3DGraph(); | ||||
tcanabrava: here too | |||||
521 | break; | ||||
522 | } | ||||
523 | } | ||||
524 | | ||||
496 | void KAlgebra::loadScript() | 525 | void KAlgebra::loadScript() | ||
497 | { | 526 | { | ||
498 | QUrl path = QFileDialog::getOpenFileUrl(this, i18n("Choose a script"), QUrl(), i18n("Script (*.kal)")); | 527 | QUrl path = QFileDialog::getOpenFileUrl(this, i18n("Choose a script"), QUrl(), i18n("Script (*.kal)")); | ||
499 | 528 | | |||
500 | if(!path.isEmpty()) | 529 | if(!path.isEmpty()) | ||
501 | loadScript(path); | 530 | loadScript(path); | ||
502 | } | 531 | } | ||
503 | 532 | | |||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
601 | } | 630 | } | ||
602 | 631 | | |||
603 | void KAlgebra::tabChanged(int n) | 632 | void KAlgebra::tabChanged(int n) | ||
604 | { | 633 | { | ||
605 | c_dock_vars->hide(); | 634 | c_dock_vars->hide(); | ||
606 | b_dock_funcs->hide(); | 635 | b_dock_funcs->hide(); | ||
607 | d_dock->hide(); | 636 | d_dock->hide(); | ||
608 | 637 | | |||
609 | menuEnabledHelper(c_menu, n==0); | | |||
610 | menuEnabledHelper(b_menu, n==1); | | |||
611 | menuEnabledHelper(t_menu, n==2); | | |||
612 | | ||||
613 | m_status->clear(); | 638 | m_status->clear(); | ||
614 | 639 | | |||
615 | switch(n) { | 640 | switch(n) { | ||
616 | case 0: | 641 | case 0: | ||
617 | c_dock_vars->show(); | 642 | c_dock_vars->show(); | ||
618 | c_dock_vars->raise(); | 643 | c_dock_vars->raise(); | ||
619 | c_exp->setFocus(); | 644 | c_exp->setFocus(); | ||
620 | break; | 645 | break; | ||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |
please use the translation functions here. it's' the i18n call.