Merge pull request #1779 from onewhl/issue801p2
Fix issue801. Made Undo button disabled when nothing to undo
This commit is contained in:
commit
7dba7bd77c
8 changed files with 76 additions and 8 deletions
|
|
@ -91,7 +91,8 @@ private slots:
|
||||||
void setColorScheme(const QString &cs);
|
void setColorScheme(const QString &cs);
|
||||||
void showProgress();
|
void showProgress();
|
||||||
void openCSGSettingsChanged();
|
void openCSGSettingsChanged();
|
||||||
void consoleOutput(const QString &msg);
|
void consoleOutput(const QString &msg);
|
||||||
|
void updateActionUndoState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initActionIcon(QAction *action, const char *darkResource, const char *lightResource);
|
void initActionIcon(QAction *action, const char *darkResource, const char *lightResource);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,16 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -30,7 +39,16 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -162,7 +180,16 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayoutAnimate">
|
<layout class="QHBoxLayout" name="horizontalLayoutAnimate">
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -245,7 +272,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1118</width>
|
<width>1118</width>
|
||||||
<height>22</height>
|
<height>19</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu_File">
|
<widget class="QMenu" name="menu_File">
|
||||||
|
|
@ -402,7 +429,16 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -528,7 +564,16 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="consoleDockContents">
|
<widget class="QWidget" name="consoleDockContents">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
|
@ -614,6 +659,9 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="editActionUndo">
|
<action name="editActionUndo">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../openscad.qrc">
|
<iconset resource="../openscad.qrc">
|
||||||
<normaloff>:/images/Command-Undo-32.png</normaloff>:/images/Command-Undo-32.png</iconset>
|
<normaloff>:/images/Command-Undo-32.png</normaloff>:/images/Command-Undo-32.png</iconset>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public:
|
||||||
virtual void replaceSelectedText(const QString &newText) = 0;
|
virtual void replaceSelectedText(const QString &newText) = 0;
|
||||||
virtual void replaceAll(const QString &findText, const QString &replaceText) = 0;
|
virtual void replaceAll(const QString &findText, const QString &replaceText) = 0;
|
||||||
virtual QStringList colorSchemes() = 0;
|
virtual QStringList colorSchemes() = 0;
|
||||||
|
virtual bool canUndo() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void contentsChanged();
|
void contentsChanged();
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,11 @@ void LegacyEditor::setText(const QString &text)
|
||||||
this->textedit->insertPlainText(text);
|
this->textedit->insertPlainText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LegacyEditor::canUndo()
|
||||||
|
{
|
||||||
|
return (this->textedit->document()->availableUndoSteps() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
void LegacyEditor::undo()
|
void LegacyEditor::undo()
|
||||||
{
|
{
|
||||||
this->textedit->undo();
|
this->textedit->undo();
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ public:
|
||||||
void replaceAll(const QString &findText, const QString &replaceText);
|
void replaceAll(const QString &findText, const QString &replaceText);
|
||||||
bool findString(const QString & exp, bool findBackwards) const;
|
bool findString(const QString & exp, bool findBackwards) const;
|
||||||
QStringList colorSchemes();
|
QStringList colorSchemes();
|
||||||
|
bool canUndo();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
|
|
|
||||||
|
|
@ -320,6 +320,7 @@ MainWindow::MainWindow(const QString &filename)
|
||||||
|
|
||||||
// Edit menu
|
// Edit menu
|
||||||
connect(this->editActionUndo, SIGNAL(triggered()), editor, SLOT(undo()));
|
connect(this->editActionUndo, SIGNAL(triggered()), editor, SLOT(undo()));
|
||||||
|
connect(editor, SIGNAL(contentsChanged()), this, SLOT(updateActionUndoState()));
|
||||||
connect(this->editActionRedo, SIGNAL(triggered()), editor, SLOT(redo()));
|
connect(this->editActionRedo, SIGNAL(triggered()), editor, SLOT(redo()));
|
||||||
connect(this->editActionRedo_2, SIGNAL(triggered()), editor, SLOT(redo()));
|
connect(this->editActionRedo_2, SIGNAL(triggered()), editor, SLOT(redo()));
|
||||||
connect(this->editActionCut, SIGNAL(triggered()), editor, SLOT(cut()));
|
connect(this->editActionCut, SIGNAL(triggered()), editor, SLOT(cut()));
|
||||||
|
|
@ -602,6 +603,11 @@ void MainWindow::addKeyboardShortCut(const QList<QAction *> &actions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateActionUndoState()
|
||||||
|
{
|
||||||
|
editActionUndo->setEnabled(editor->canUndo());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::loadViewSettings(){
|
void MainWindow::loadViewSettings(){
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
if (settings.value("view/showEdges").toBool()) {
|
if (settings.value("view/showEdges").toBool()) {
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,11 @@ QStringList ScintillaEditor::colorSchemes()
|
||||||
return colorSchemes;
|
return colorSchemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScintillaEditor::canUndo()
|
||||||
|
{
|
||||||
|
return qsci->isUndoAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
void ScintillaEditor::setHighlightScheme(const QString &name)
|
void ScintillaEditor::setHighlightScheme(const QString &name)
|
||||||
{
|
{
|
||||||
const colorscheme_set_t colorscheme_set = enumerateColorSchemes();
|
const colorscheme_set_t colorscheme_set = enumerateColorSchemes();
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@ public:
|
||||||
void replaceSelectedText(const QString&);
|
void replaceSelectedText(const QString&);
|
||||||
void replaceAll(const QString &findText, const QString &replaceText);
|
void replaceAll(const QString &findText, const QString &replaceText);
|
||||||
QStringList colorSchemes();
|
QStringList colorSchemes();
|
||||||
|
bool canUndo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getRange(int *lineFrom, int *lineTo);
|
void getRange(int *lineFrom, int *lineTo);
|
||||||
void setColormap(const EditorColorScheme *colorScheme);
|
void setColormap(const EditorColorScheme *colorScheme);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue