terminal start delay

This commit is contained in:
Zira project 2020-06-02 18:45:37 +05:00
parent 0683b6d7d4
commit 422bbdd4f8
6 changed files with 17 additions and 1 deletions

View file

@ -229,6 +229,7 @@ private slots:
void terminalCopy();
void terminalPaste();
void showTerminal();
void startTerminal();
private:
Ui::MainWindow *ui;
Settings * settings;

View file

@ -17,6 +17,7 @@ public:
virtual void changeDir(QString path) = 0;
virtual void copy() = 0;
virtual void paste() = 0;
virtual void startShell() = 0;
};
#define TerminalInterface_iid "com.github.ziracms.editor.TerminalInterface"

View file

@ -11,7 +11,6 @@ void TerminalPlugin::initialize(QString path)
console->setEnvironment(QStringList() << "TERM=konsole-256color");
console->setColorScheme("Linux"); // "GreenOnBlack", "Linux", "SolarizedLight", "BlackOnWhite", "DarkPastels", "BlackOnRandomLight", "WhiteOnBlack", "BlackOnLightYellow", "Solarized", "BreezeModified"
console->setWorkingDirectory(path);
console->startShellProgram();
}
QString TerminalPlugin::getDirName()
@ -48,3 +47,8 @@ void TerminalPlugin::changeDir(QString path)
{
console->changeDir(path);
}
void TerminalPlugin::startShell()
{
console->startShellProgram();
}

View file

@ -22,6 +22,7 @@ public:
void changeDir(QString path) override;
void copy() override;
void paste() override;
void startShell() override;
private:
QTermWidget * console;
};

View file

@ -43,6 +43,7 @@ const int SIDEBAR_TAB_NAVIGATOR_INDEX = 1;
const int SIDEBAR_TAB_GIT_BROWSER_INDEX = 2;
int const MainWindow::EXIT_CODE_RESTART = -123456789;
int const TERMINAL_START_DELAY = 250; // should not be less then PROJECT_LOAD_DELAY
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@ -442,6 +443,8 @@ MainWindow::MainWindow(QWidget *parent) :
QString showTerminalStr = QString::fromStdString(settings->get("shortcut_terminal"));
QShortcut * showTerminal = new QShortcut(QKeySequence(showTerminalStr), this);
connect(showTerminal, SIGNAL(activated()), this, SLOT(showTerminal()));
QTimer::singleShot(TERMINAL_START_DELAY, this, SLOT(startTerminal()));
} else {
terminalTabIndex = -1;
}
@ -2468,3 +2471,9 @@ void MainWindow::terminalPaste()
if (terminal == nullptr) return;
terminal->paste();
}
void MainWindow::startTerminal()
{
if (terminal == nullptr) return;
terminal->startShell();
}