1
0
Fork 0

Fetch mCmdHistory on an empty mCmdLineEdit

This commit is contained in:
lyflow 2019-05-31 17:34:49 -04:00 committed by Duncan Ogilvie
parent 1f0577ff68
commit 6a02c7863b
3 changed files with 13 additions and 1 deletions

View File

@ -46,6 +46,14 @@ void HistoryLineEdit::addLineToHistory(QString parLine)
mCmdIndex = -1;
}
QString HistoryLineEdit::getLineFromHistory()
{
if(mCmdHistory.empty())
return "";
else
return mCmdHistory.first();
}
QString HistoryLineEdit::addHistoryClear()
{
auto str = text();

View File

@ -11,6 +11,7 @@ public:
explicit HistoryLineEdit(QWidget* parent = 0);
void keyPressEvent(QKeyEvent* event);
void addLineToHistory(QString parLine);
QString getLineFromHistory();
QString addHistoryClear();
void setFocus();
void loadSettings(QString sectionPrefix);

View File

@ -113,10 +113,13 @@ void CommandLineEdit::execute()
if(mCurrentScriptIndex == -1)
return;
GUISCRIPTEXECUTE exec = mScriptInfo[mCurrentScriptIndex].execute;
const QString & cmd = text();
QString & cmd = text();
if(exec)
{
if(cmd.trimmed().isEmpty())
cmd = getLineFromHistory();
// Send this string directly to the user
exec(cmd.toUtf8().constData());
}