Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add scheme style with terminal #909

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions src/plugins/console/color-schemes/Dark.colorscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

[Background]
Bold=true
Color=37,37,37
Transparency=false

[BackgroundIntense]
Bold=true
Color=0,0,0
Transparency=false

[Color0]
Bold=true
Color=0,0,0
Transparency=false

[Color0Intense]
Bold=true
Color=104,104,104
Transparency=false

[Color1]
Bold=true
Color=178,24,24
Transparency=false

[Color1Intense]
Bold=true
Color=255,84,84
Transparency=false

[Color2]
Bold=true
Color=24,178,24
Transparency=false

[Color2Intense]
Bold=true
Color=133,153,0
Transparency=false

[Color3]
Bold=true
Color=178,104,24
Transparency=false

[Color3Intense]
Bold=true
Color=255,255,84
Transparency=false

[Color4]
Bold=true
Color=52,101,164
Transparency=false

[Color4Intense]
Bold=true
Color=52,101,164
Transparency=false

[Color5]
Bold=true
Color=225,30,225
Transparency=false

[Color5Intense]
Bold=true
Color=30,144,255
Transparency=false

[Color6]
Bold=true
Color=24,178,178
Transparency=false

[Color6Intense]
Bold=true
Color=253,246,227
Transparency=false

[Color7]
Bold=true
Color=238,232,213
Transparency=false

[Color7Intense]
Bold=true
Color=255,255,255
Transparency=false

[Foreground]
Bold=true
Color=0,205,0
Transparency=false

[ForegroundIntense]
Bold=true
Color=0,205,0
Transparency=false

[General]
Description=Green on Black
Opacity=1
104 changes: 104 additions & 0 deletions src/plugins/console/color-schemes/Light.colorscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

[Background]
Bold=true
Color=248,248,248
Transparency=false

[BackgroundIntense]
Bold=true
Color=255,255,255
Transparency=false

[Color0]
Bold=true
Color=0,0,0
Transparency=false

[Color0Intense]
Bold=true
Color=104,104,104
Transparency=false

[Color1]
Bold=true
Color=178,24,24
Transparency=false

[Color1Intense]
Bold=true
Color=255,84,84
Transparency=false

[Color2]
Bold=true
Color=24,178,24
Transparency=false

[Color2Intense]
Bold=true
Color=133,153,0
Transparency=false

[Color3]
Bold=true
Color=178,104,24
Transparency=false

[Color3Intense]
Bold=true
Color=233,233,79
Transparency=false

[Color4]
Bold=true
Color=24,24,178
Transparency=false

[Color4Intense]
Bold=true
Color=52,101,164
Transparency=false

[Color5]
Bold=true
Color=225,30,225
Transparency=false

[Color5Intense]
Bold=true
Color=30,144,255
Transparency=false

[Color6]
Bold=true
Color=24,178,178
Transparency=false

[Color6Intense]
Bold=true
Color=24,178,178
Transparency=false

[Color7]
Bold=true
Color=238,232,213
Transparency=false

[Color7Intense]
Bold=true
Color=238,232,213
Transparency=false

[Foreground]
Bold=true
Color=0,0,0
Transparency=false

[ForegroundIntense]
Bold=true
Color=0,0,0
Transparency=false

[General]
Description=Green on Black
Opacity=1
8 changes: 8 additions & 0 deletions src/plugins/console/console.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/icons/deepin/builtin"/>
<qresource prefix="/icons/deepin"/>
<qresource prefix="/">
<file>color-schemes/Dark.colorscheme</file>
<file>color-schemes/Light.colorscheme</file>
</qresource>
</RCC>
25 changes: 20 additions & 5 deletions src/plugins/console/consolewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <DMenu>

#include <QDir>
#include <QDebug>

DWIDGET_USE_NAMESPACE
Expand All @@ -32,6 +33,12 @@ ConsoleWidget::ConsoleWidget(QWidget *parent, bool startNow)
setAutoFillBackground(true);
setTerminalOpacity(1);

// using default deepin-terminal style schemes
// U can see schemes path with deepin-os
QString sys_schemes_path = "/usr/share/terminalwidget5/color-schemes";
if (QDir(sys_schemes_path).exists())
addCustomColorSchemeDir(sys_schemes_path);

auto theme = DGuiApplicationHelper::instance()->themeType();
updateColorScheme(theme);
if (availableKeyBindings().contains("linux"))
Expand Down Expand Up @@ -85,11 +92,19 @@ void ConsoleWidget::contextMenuEvent(QContextMenuEvent *event)

void ConsoleWidget::updateColorScheme(DGuiApplicationHelper::ColorType themetype)
{
if (themetype == DGuiApplicationHelper::DarkType
&& availableColorSchemes().contains("Linux"))
this->setColorScheme("Linux");
else if (availableColorSchemes().contains("BlackOnWhite"))
this->setColorScheme("BlackOnWhite");
if (DGuiApplicationHelper::DarkType == themetype) {
// need add member option setting check logic
if (availableColorSchemes().contains("Dark"))
this->setColorScheme("Dark");
else
this->setColorScheme(":/color-schemes/Dark.colorscheme");
} else if (DGuiApplicationHelper::LightType == themetype) {
// need add member option setting check logic
if (availableColorSchemes().contains("Light"))
this->setColorScheme("Light");
else
this->setColorScheme(":/color-schemes/Light.colorscheme");
}
}

void ConsoleWidget::enterCurrentProjectPath()
Expand Down
Loading