| 28 | }; |
| 29 | |
| 30 | ConsoleWidget::ConsoleWidget(QWidget *parent, bool startNow) |
| 31 | : QTermWidget(startNow, parent), |
| 32 | d(new ConsoleWidgetPrivate()) |
| 33 | { |
| 34 | setMargin(0); |
| 35 | setForegroundRole(QPalette::ColorRole::Window); |
| 36 | setAutoFillBackground(true); |
| 37 | setTerminalOpacity(1); |
| 38 | |
| 39 | // using default deepin-terminal style schemes |
| 40 | // U can see schemes path with deepin-os |
| 41 | QString sys_schemes_path = "/usr/share/terminalwidget5/color-schemes"; |
| 42 | if (QDir(sys_schemes_path).exists()) |
| 43 | addCustomColorSchemeDir(sys_schemes_path); |
| 44 | |
| 45 | auto theme = DGuiApplicationHelper::instance()->themeType(); |
| 46 | updateColorScheme(theme); |
| 47 | if (availableKeyBindings().contains("linux")) |
| 48 | setKeyBindings("linux"); |
| 49 | |
| 50 | setScrollBarPosition(QTermWidget::ScrollBarRight); |
| 51 | setTerminalSizeHint(false); |
| 52 | setAutoClose(false); |
| 53 | |
| 54 | d->prjService = dpfGetService(ProjectService); |
| 55 | changeDir(d->prjService->getActiveProjectInfo().workspaceFolder()); |
| 56 | sendText("clear\n"); |
| 57 | |
| 58 | d->inputWidget = new GenerateInput(this); |
| 59 | d->inputWidget->hide(); |
| 60 | auto layout = this->layout(); |
| 61 | if (layout) |
| 62 | layout->addWidget(d->inputWidget); |
| 63 | |
| 64 | d->consoleCopy = new QAction(tr("copy"), this); |
| 65 | d->consolePaste = new QAction(tr("paste"), this); |
| 66 | d->enterCurrentPath = new QAction(tr("Enter current project root path"), this); |
| 67 | d->showInputWidget = new QAction(tr("Intelligent Command Generation"), this); |
| 68 | QObject::connect(d->consoleCopy, &QAction::triggered, this, &QTermWidget::copyClipboard); |
| 69 | QObject::connect(d->consolePaste, &QAction::triggered, this, &QTermWidget::pasteClipboard); |
| 70 | QObject::connect(d->enterCurrentPath, &QAction::triggered, this, &ConsoleWidget::enterCurrentProjectPath); |
| 71 | QObject::connect(d->showInputWidget, &QAction::triggered, d->inputWidget, &GenerateInput::show); |
| 72 | QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, |
| 73 | this, &ConsoleWidget::updateColorScheme); |
| 74 | QObject::connect(d->inputWidget, &GenerateInput::commandGenerated, this, &ConsoleWidget::sendText); |
| 75 | } |
| 76 | |
| 77 | ConsoleWidget::~ConsoleWidget() |
| 78 | { |
nothing calls this directly
no test coverage detected