|
|
|
@ -50,7 +50,7 @@
|
|
|
|
|
#include "abakuslistview.h"
|
|
|
|
|
#include "result.h"
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow() : KMainWindow(0, "abakus-mainwindow"), m_popup(0), m_insert(false)
|
|
|
|
|
MainWindow::MainWindow() : TDEMainWindow(0, "abakus-mainwindow"), m_popup(0), m_insert(false)
|
|
|
|
|
{
|
|
|
|
|
m_mainSplitter = new TQSplitter(this);
|
|
|
|
|
TQWidget *box = new TQWidget(m_mainSplitter);
|
|
|
|
@ -156,36 +156,36 @@ MainWindow::MainWindow() : KMainWindow(0, "abakus-mainwindow"), m_popup(0), m_in
|
|
|
|
|
|
|
|
|
|
bool MainWindow::inRPNMode() const
|
|
|
|
|
{
|
|
|
|
|
return action<KToggleAction>("toggleExpressionMode")->isChecked();
|
|
|
|
|
return action<TDEToggleAction>("toggleExpressionMode")->isChecked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::eventFilter(TQObject *o, TQEvent *e)
|
|
|
|
|
{
|
|
|
|
|
return KMainWindow::eventFilter(o, e);
|
|
|
|
|
return TDEMainWindow::eventFilter(o, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::queryExit()
|
|
|
|
|
{
|
|
|
|
|
saveConfig();
|
|
|
|
|
return KMainWindow::queryExit();
|
|
|
|
|
return TDEMainWindow::queryExit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::contextMenuEvent(TQContextMenuEvent *e)
|
|
|
|
|
{
|
|
|
|
|
static KPopupMenu *popup = 0;
|
|
|
|
|
static TDEPopupMenu *popup = 0;
|
|
|
|
|
|
|
|
|
|
if(!popup) {
|
|
|
|
|
popup = new KPopupMenu(this);
|
|
|
|
|
popup = new TDEPopupMenu(this);
|
|
|
|
|
action("options_show_menubar")->plug(popup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!action<KToggleAction>("options_show_menubar")->isChecked())
|
|
|
|
|
if(!action<TDEToggleAction>("options_show_menubar")->isChecked())
|
|
|
|
|
popup->popup(e->globalPos());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::polish()
|
|
|
|
|
{
|
|
|
|
|
KMainWindow::polish();
|
|
|
|
|
TDEMainWindow::polish();
|
|
|
|
|
loadConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -326,7 +326,7 @@ void MainWindow::slotDegrees()
|
|
|
|
|
setTrigMode(Abakus::Degrees);
|
|
|
|
|
m_degrees->setChecked(true);
|
|
|
|
|
if(action("setDegreesMode"))
|
|
|
|
|
action<KToggleAction>("setDegreesMode")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("setDegreesMode")->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotRadians()
|
|
|
|
@ -334,7 +334,7 @@ void MainWindow::slotRadians()
|
|
|
|
|
setTrigMode(Abakus::Radians);
|
|
|
|
|
m_radians->setChecked(true);
|
|
|
|
|
if(action("setRadiansMode"))
|
|
|
|
|
action<KToggleAction>("setRadiansMode")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("setRadiansMode")->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int MainWindow::getParenthesesLevel(const TQString &str)
|
|
|
|
@ -366,7 +366,7 @@ void MainWindow::loadConfig()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool useRPN = config.readBoolEntry("Use RPN Mode", false);
|
|
|
|
|
action<KToggleAction>("toggleExpressionMode")->setChecked(useRPN);
|
|
|
|
|
action<TDEToggleAction>("toggleExpressionMode")->setChecked(useRPN);
|
|
|
|
|
|
|
|
|
|
int precision = config.readNumEntry("Decimal Precision", -1);
|
|
|
|
|
if(precision < -1 || precision > 75)
|
|
|
|
@ -395,20 +395,20 @@ void MainWindow::loadConfig()
|
|
|
|
|
TDEConfigGroup config(TDEGlobal::config(), "GUI");
|
|
|
|
|
|
|
|
|
|
bool showHistory = config.readBoolEntry("ShowHistory", true);
|
|
|
|
|
action<KToggleAction>("toggleHistoryList")->setChecked(showHistory);
|
|
|
|
|
action<TDEToggleAction>("toggleHistoryList")->setChecked(showHistory);
|
|
|
|
|
m_history->setShown(showHistory);
|
|
|
|
|
|
|
|
|
|
bool showFunctions = config.readBoolEntry("ShowFunctions", true);
|
|
|
|
|
action<KToggleAction>("toggleFunctionList")->setChecked(showFunctions);
|
|
|
|
|
action<TDEToggleAction>("toggleFunctionList")->setChecked(showFunctions);
|
|
|
|
|
m_fnList->setShown(showFunctions);
|
|
|
|
|
|
|
|
|
|
bool showVariables = config.readBoolEntry("ShowVariables", true);
|
|
|
|
|
action<KToggleAction>("toggleVariableList")->setChecked(showVariables);
|
|
|
|
|
action<TDEToggleAction>("toggleVariableList")->setChecked(showVariables);
|
|
|
|
|
m_varList->setShown(showVariables);
|
|
|
|
|
|
|
|
|
|
bool compactMode = config.readBoolEntry("InCompactMode", false);
|
|
|
|
|
compactMode = compactMode || !showHistory;
|
|
|
|
|
action<KToggleAction>("toggleCompactMode")->setChecked(compactMode);
|
|
|
|
|
action<TDEToggleAction>("toggleCompactMode")->setChecked(compactMode);
|
|
|
|
|
|
|
|
|
|
if(compactMode)
|
|
|
|
|
TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotToggleCompactMode()));
|
|
|
|
@ -463,7 +463,7 @@ void MainWindow::saveConfig()
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
TDEConfigGroup config(TDEGlobal::config(), "GUI");
|
|
|
|
|
bool inCompactMode = action<KToggleAction>("toggleCompactMode")->isChecked();
|
|
|
|
|
bool inCompactMode = action<TDEToggleAction>("toggleCompactMode")->isChecked();
|
|
|
|
|
|
|
|
|
|
config.writeEntry("InCompactMode", inCompactMode);
|
|
|
|
|
|
|
|
|
@ -501,62 +501,62 @@ void MainWindow::saveConfig()
|
|
|
|
|
|
|
|
|
|
void MainWindow::setupLayout()
|
|
|
|
|
{
|
|
|
|
|
KActionCollection *ac = actionCollection();
|
|
|
|
|
TDEActionCollection *ac = actionCollection();
|
|
|
|
|
|
|
|
|
|
KStdAction::quit(TQT_TQOBJECT(kapp), TQT_SLOT(quit()), ac);
|
|
|
|
|
KStdAction::showMenubar(TQT_TQOBJECT(this), TQT_SLOT(slotToggleMenuBar()), ac);
|
|
|
|
|
|
|
|
|
|
KToggleAction *ta = new KToggleAction(i18n("&Degrees"), SHIFT + ALT + Key_D, TQT_TQOBJECT(this), TQT_SLOT(slotDegrees()), ac, "setDegreesMode");
|
|
|
|
|
TDEToggleAction *ta = new TDEToggleAction(i18n("&Degrees"), SHIFT + ALT + Key_D, TQT_TQOBJECT(this), TQT_SLOT(slotDegrees()), ac, "setDegreesMode");
|
|
|
|
|
ta->setExclusiveGroup("TrigMode");
|
|
|
|
|
ta->setChecked(trigMode() == Abakus::Degrees);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("&Radians"), SHIFT + ALT + Key_R, TQT_TQOBJECT(this), TQT_SLOT(slotRadians()), ac, "setRadiansMode");
|
|
|
|
|
ta = new TDEToggleAction(i18n("&Radians"), SHIFT + ALT + Key_R, TQT_TQOBJECT(this), TQT_SLOT(slotRadians()), ac, "setRadiansMode");
|
|
|
|
|
ta->setExclusiveGroup("TrigMode");
|
|
|
|
|
ta->setChecked(trigMode() == Abakus::Radians);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("Show &History List"), SHIFT + ALT + Key_H, TQT_TQOBJECT(this), TQT_SLOT(slotToggleHistoryList()), ac, "toggleHistoryList");
|
|
|
|
|
ta = new TDEToggleAction(i18n("Show &History List"), SHIFT + ALT + Key_H, TQT_TQOBJECT(this), TQT_SLOT(slotToggleHistoryList()), ac, "toggleHistoryList");
|
|
|
|
|
ta->setChecked(true);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("Show &Variables"), SHIFT + ALT + Key_V, TQT_TQOBJECT(this), TQT_SLOT(slotToggleVariableList()), ac, "toggleVariableList");
|
|
|
|
|
ta = new TDEToggleAction(i18n("Show &Variables"), SHIFT + ALT + Key_V, TQT_TQOBJECT(this), TQT_SLOT(slotToggleVariableList()), ac, "toggleVariableList");
|
|
|
|
|
ta->setChecked(true);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("Show &Functions"), SHIFT + ALT + Key_F, TQT_TQOBJECT(this), TQT_SLOT(slotToggleFunctionList()), ac, "toggleFunctionList");
|
|
|
|
|
ta = new TDEToggleAction(i18n("Show &Functions"), SHIFT + ALT + Key_F, TQT_TQOBJECT(this), TQT_SLOT(slotToggleFunctionList()), ac, "toggleFunctionList");
|
|
|
|
|
ta->setChecked(true);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("Activate &Compact Mode"), SHIFT + ALT + Key_C, TQT_TQOBJECT(this), TQT_SLOT(slotToggleCompactMode()), ac, "toggleCompactMode");
|
|
|
|
|
ta = new TDEToggleAction(i18n("Activate &Compact Mode"), SHIFT + ALT + Key_C, TQT_TQOBJECT(this), TQT_SLOT(slotToggleCompactMode()), ac, "toggleCompactMode");
|
|
|
|
|
ta->setChecked(false);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("Use R&PN Mode"), SHIFT + ALT + Key_P, TQT_TQOBJECT(this), TQT_SLOT(slotToggleExpressionMode()), ac, "toggleExpressionMode");
|
|
|
|
|
ta = new TDEToggleAction(i18n("Use R&PN Mode"), SHIFT + ALT + Key_P, TQT_TQOBJECT(this), TQT_SLOT(slotToggleExpressionMode()), ac, "toggleExpressionMode");
|
|
|
|
|
ta->setChecked(false);
|
|
|
|
|
|
|
|
|
|
// Precision actions.
|
|
|
|
|
ta = new KToggleAction(i18n("&Automatic Precision"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecisionAuto()), ac, "precisionAuto");
|
|
|
|
|
ta = new TDEToggleAction(i18n("&Automatic Precision"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecisionAuto()), ac, "precisionAuto");
|
|
|
|
|
ta->setExclusiveGroup("Precision");
|
|
|
|
|
ta->setChecked(true);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("&3 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision3()), ac, "precision3");
|
|
|
|
|
ta = new TDEToggleAction(i18n("&3 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision3()), ac, "precision3");
|
|
|
|
|
ta->setExclusiveGroup("Precision");
|
|
|
|
|
ta->setChecked(false);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("&8 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision8()), ac, "precision8");
|
|
|
|
|
ta = new TDEToggleAction(i18n("&8 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision8()), ac, "precision8");
|
|
|
|
|
ta->setExclusiveGroup("Precision");
|
|
|
|
|
ta->setChecked(false);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("&15 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision15()), ac, "precision15");
|
|
|
|
|
ta = new TDEToggleAction(i18n("&15 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision15()), ac, "precision15");
|
|
|
|
|
ta->setExclusiveGroup("Precision");
|
|
|
|
|
ta->setChecked(false);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("&50 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision50()), ac, "precision50");
|
|
|
|
|
ta = new TDEToggleAction(i18n("&50 Decimal Digits"), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecision50()), ac, "precision50");
|
|
|
|
|
ta->setExclusiveGroup("Precision");
|
|
|
|
|
ta->setChecked(false);
|
|
|
|
|
|
|
|
|
|
ta = new KToggleAction(i18n("C&ustom Precision..."), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecisionCustom()), ac, "precisionCustom");
|
|
|
|
|
ta = new TDEToggleAction(i18n("C&ustom Precision..."), 0, TQT_TQOBJECT(this), TQT_SLOT(slotPrecisionCustom()), ac, "precisionCustom");
|
|
|
|
|
ta->setExclusiveGroup("Precision");
|
|
|
|
|
ta->setChecked(false);
|
|
|
|
|
|
|
|
|
|
new KAction(i18n("Clear &History"), "editclear", SHIFT + ALT + Key_L, TQT_TQOBJECT(m_result), TQT_SLOT(clear()), ac, "clearHistory");
|
|
|
|
|
new TDEAction(i18n("Clear &History"), "editclear", SHIFT + ALT + Key_L, TQT_TQOBJECT(m_result), TQT_SLOT(clear()), ac, "clearHistory");
|
|
|
|
|
|
|
|
|
|
new KAction(i18n("Select Editor"), "goto", Key_F6, TQT_TQOBJECT(m_edit), TQT_SLOT(setFocus()), ac, "select_edit");
|
|
|
|
|
new TDEAction(i18n("Select Editor"), "goto", Key_F6, TQT_TQOBJECT(m_edit), TQT_SLOT(setFocus()), ac, "select_edit");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::populateListViews()
|
|
|
|
@ -570,7 +570,7 @@ void MainWindow::populateListViews()
|
|
|
|
|
new ValueListViewItem(m_varList, "e", value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KAction *MainWindow::action(const char *key) const
|
|
|
|
|
TDEAction *MainWindow::action(const char *key) const
|
|
|
|
|
{
|
|
|
|
|
return actionCollection()->action(key);
|
|
|
|
|
}
|
|
|
|
@ -593,38 +593,38 @@ void MainWindow::slotToggleMenuBar()
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotToggleFunctionList()
|
|
|
|
|
{
|
|
|
|
|
bool show = action<KToggleAction>("toggleFunctionList")->isChecked();
|
|
|
|
|
bool show = action<TDEToggleAction>("toggleFunctionList")->isChecked();
|
|
|
|
|
m_fnList->setShown(show);
|
|
|
|
|
|
|
|
|
|
if(!m_history->isShown()) {
|
|
|
|
|
m_history->setShown(true);
|
|
|
|
|
action<KToggleAction>("toggleHistoryList")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("toggleHistoryList")->setChecked(true);
|
|
|
|
|
slotToggleHistoryList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
action<KToggleAction>("toggleCompactMode")->setChecked(false);
|
|
|
|
|
action<TDEToggleAction>("toggleCompactMode")->setChecked(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotToggleVariableList()
|
|
|
|
|
{
|
|
|
|
|
bool show = action<KToggleAction>("toggleVariableList")->isChecked();
|
|
|
|
|
bool show = action<TDEToggleAction>("toggleVariableList")->isChecked();
|
|
|
|
|
m_varList->setShown(show);
|
|
|
|
|
|
|
|
|
|
if(!m_history->isShown()) {
|
|
|
|
|
m_history->setShown(true);
|
|
|
|
|
action<KToggleAction>("toggleHistoryList")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("toggleHistoryList")->setChecked(true);
|
|
|
|
|
slotToggleHistoryList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
action<KToggleAction>("toggleCompactMode")->setChecked(false);
|
|
|
|
|
action<TDEToggleAction>("toggleCompactMode")->setChecked(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotToggleHistoryList()
|
|
|
|
|
{
|
|
|
|
|
bool show = action<KToggleAction>("toggleHistoryList")->isChecked();
|
|
|
|
|
bool show = action<TDEToggleAction>("toggleHistoryList")->isChecked();
|
|
|
|
|
m_history->setShown(show);
|
|
|
|
|
|
|
|
|
|
action<KToggleAction>("toggleCompactMode")->setChecked(false);
|
|
|
|
|
action<TDEToggleAction>("toggleCompactMode")->setChecked(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotNewFunction(const TQString &name)
|
|
|
|
@ -634,7 +634,7 @@ void MainWindow::slotNewFunction(const TQString &name)
|
|
|
|
|
TQString fnName = TQString("%1(%2)").arg(name, userFn->varName);
|
|
|
|
|
TQString expr = fn->operand()->infixString();
|
|
|
|
|
|
|
|
|
|
new KListViewItem(m_fnList, fnName, expr);
|
|
|
|
|
new TDEListViewItem(m_fnList, fnName, expr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotRemoveFunction(const TQString &name)
|
|
|
|
@ -667,7 +667,7 @@ void MainWindow::slotRemoveValue(const TQString &name)
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotToggleCompactMode()
|
|
|
|
|
{
|
|
|
|
|
if(action<KToggleAction>("toggleCompactMode")->isChecked()) {
|
|
|
|
|
if(action<TDEToggleAction>("toggleCompactMode")->isChecked()) {
|
|
|
|
|
m_wasFnShown = m_fnList->isShown();
|
|
|
|
|
m_wasVarShown = m_varList->isShown();
|
|
|
|
|
m_wasHistoryShown = m_history->isShown();
|
|
|
|
@ -676,9 +676,9 @@ void MainWindow::slotToggleCompactMode()
|
|
|
|
|
m_varList->setShown(false);
|
|
|
|
|
m_history->setShown(false);
|
|
|
|
|
|
|
|
|
|
action<KToggleAction>("toggleFunctionList")->setChecked(false);
|
|
|
|
|
action<KToggleAction>("toggleVariableList")->setChecked(false);
|
|
|
|
|
action<KToggleAction>("toggleHistoryList")->setChecked(false);
|
|
|
|
|
action<TDEToggleAction>("toggleFunctionList")->setChecked(false);
|
|
|
|
|
action<TDEToggleAction>("toggleVariableList")->setChecked(false);
|
|
|
|
|
action<TDEToggleAction>("toggleHistoryList")->setChecked(false);
|
|
|
|
|
|
|
|
|
|
m_oldSize = size();
|
|
|
|
|
m_newSize = TQSize(0, 0);
|
|
|
|
@ -689,9 +689,9 @@ void MainWindow::slotToggleCompactMode()
|
|
|
|
|
m_varList->setShown(m_wasVarShown);
|
|
|
|
|
m_history->setShown(m_wasHistoryShown);
|
|
|
|
|
|
|
|
|
|
action<KToggleAction>("toggleFunctionList")->setChecked(m_wasFnShown);
|
|
|
|
|
action<KToggleAction>("toggleVariableList")->setChecked(m_wasVarShown);
|
|
|
|
|
action<KToggleAction>("toggleHistoryList")->setChecked(m_wasHistoryShown);
|
|
|
|
|
action<TDEToggleAction>("toggleFunctionList")->setChecked(m_wasFnShown);
|
|
|
|
|
action<TDEToggleAction>("toggleVariableList")->setChecked(m_wasVarShown);
|
|
|
|
|
action<TDEToggleAction>("toggleHistoryList")->setChecked(m_wasHistoryShown);
|
|
|
|
|
|
|
|
|
|
m_newSize = m_oldSize;
|
|
|
|
|
TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotUpdateSize()));
|
|
|
|
@ -796,27 +796,27 @@ void MainWindow::selectCorrectPrecisionAction()
|
|
|
|
|
{
|
|
|
|
|
switch(Abakus::m_prec) {
|
|
|
|
|
case 3:
|
|
|
|
|
action<KToggleAction>("precision3")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("precision3")->setChecked(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
action<KToggleAction>("precision8")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("precision8")->setChecked(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
|
action<KToggleAction>("precision15")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("precision15")->setChecked(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 50:
|
|
|
|
|
action<KToggleAction>("precision50")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("precision50")->setChecked(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
|
action<KToggleAction>("precisionAuto")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("precisionAuto")->setChecked(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
action<KToggleAction>("precisionCustom")->setChecked(true);
|
|
|
|
|
action<TDEToggleAction>("precisionCustom")->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|