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 showProgress();
|
||||
void openCSGSettingsChanged();
|
||||
void consoleOutput(const QString &msg);
|
||||
void consoleOutput(const QString &msg);
|
||||
void updateActionUndoState();
|
||||
|
||||
private:
|
||||
void initActionIcon(QAction *action, const char *darkResource, const char *lightResource);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,16 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</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>
|
||||
</property>
|
||||
<item>
|
||||
|
|
@ -30,7 +39,16 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</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>
|
||||
</property>
|
||||
<item>
|
||||
|
|
@ -162,7 +180,16 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
</property>
|
||||
<item>
|
||||
|
|
@ -245,7 +272,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1118</width>
|
||||
<height>22</height>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
|
|
@ -402,7 +429,16 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</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>
|
||||
</property>
|
||||
<item>
|
||||
|
|
@ -528,7 +564,16 @@
|
|||
</attribute>
|
||||
<widget class="QWidget" name="consoleDockContents">
|
||||
<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>
|
||||
</property>
|
||||
<item>
|
||||
|
|
@ -614,6 +659,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="editActionUndo">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../openscad.qrc">
|
||||
<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 replaceAll(const QString &findText, const QString &replaceText) = 0;
|
||||
virtual QStringList colorSchemes() = 0;
|
||||
virtual bool canUndo() = 0;
|
||||
|
||||
signals:
|
||||
void contentsChanged();
|
||||
|
|
|
|||
|
|
@ -185,6 +185,11 @@ void LegacyEditor::setText(const QString &text)
|
|||
this->textedit->insertPlainText(text);
|
||||
}
|
||||
|
||||
bool LegacyEditor::canUndo()
|
||||
{
|
||||
return (this->textedit->document()->availableUndoSteps() != 0);
|
||||
}
|
||||
|
||||
void LegacyEditor::undo()
|
||||
{
|
||||
this->textedit->undo();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public:
|
|||
void replaceAll(const QString &findText, const QString &replaceText);
|
||||
bool findString(const QString & exp, bool findBackwards) const;
|
||||
QStringList colorSchemes();
|
||||
bool canUndo();
|
||||
|
||||
public slots:
|
||||
void zoomIn();
|
||||
|
|
|
|||
|
|
@ -320,6 +320,7 @@ MainWindow::MainWindow(const QString &filename)
|
|||
|
||||
// Edit menu
|
||||
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_2, SIGNAL(triggered()), editor, SLOT(redo()));
|
||||
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(){
|
||||
QSettings settings;
|
||||
if (settings.value("view/showEdges").toBool()) {
|
||||
|
|
|
|||
|
|
@ -421,6 +421,11 @@ QStringList ScintillaEditor::colorSchemes()
|
|||
return colorSchemes;
|
||||
}
|
||||
|
||||
bool ScintillaEditor::canUndo()
|
||||
{
|
||||
return qsci->isUndoAvailable();
|
||||
}
|
||||
|
||||
void ScintillaEditor::setHighlightScheme(const QString &name)
|
||||
{
|
||||
const colorscheme_set_t colorscheme_set = enumerateColorSchemes();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ public:
|
|||
void replaceSelectedText(const QString&);
|
||||
void replaceAll(const QString &findText, const QString &replaceText);
|
||||
QStringList colorSchemes();
|
||||
|
||||
bool canUndo();
|
||||
|
||||
private:
|
||||
void getRange(int *lineFrom, int *lineTo);
|
||||
void setColormap(const EditorColorScheme *colorScheme);
|
||||
|
|
|
|||
Loading…
Reference in a new issue