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

feat: 常用应用库页面添加应用商店入口 #469

Merged
merged 1 commit into from
Mar 8, 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
10 changes: 10 additions & 0 deletions src/base/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,16 @@ bool Utils::hasSelperSupport()
return false;
}

bool Utils::hasAppStore()
{
const QStringList list = getSystemManualList();
if (list.contains("deepin-app-store")) {
return true;
} else {
return false;
}
}

//p表示桌面专业版,h表示个人版,d表示社区版
//s表示默认服务器版,e表示服务器企业版,eu表示服务器欧拉版,i表示服务器行业版,klu表示KelvinU项目版本,pgv表示PanguV项目版本。
QStringList Utils::systemToOmit(Dtk::Core::DSysInfo::UosEdition type)
Expand Down
1 change: 1 addition & 0 deletions src/base/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Utils : public QObject
static QStringList getSystemManualDir();
static QList<AppInfo> sortAppList(QMultiMap<qlonglong, AppInfo> map);
static bool hasSelperSupport();
static bool hasAppStore();
static QStringList systemToOmit(Dtk::Core::DSysInfo::UosEdition);
static bool activeWindow(quintptr winId);
static QString regexp_label(const QString &strtext, const QString &strpatter);
Expand Down
3 changes: 2 additions & 1 deletion src/view/i18n_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ QVariantHash I18nProxy::getSentences() const
{"ResultNumSuffixs", QObject::tr(" results")},
{"ClicktoView", QObject::tr("Click to view ")},
{"ViewAll", QObject::tr("View all")},
{"Support", QObject::tr("Support")}
{"Support", QObject::tr("Support")},
{"AppStore", QObject::tr("App Store")}
};

return result;
Expand Down
11 changes: 11 additions & 0 deletions src/view/manual_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ bool ManualProxy::hasSelperSupport()
return b;
}

bool ManualProxy::hasAppStore()
{
bool b = Utils::hasAppStore();
return b;
}

/**
* @brief ManualProxy::finishChannel
* 完成channel对象与Qt对象绑定后调用WebWindow中的onChannelFinish方法
Expand All @@ -131,6 +137,11 @@ void ManualProxy::supportClick()
emit supportBeClick();
}

void ManualProxy::appStoreClick()
{
emit appStoreBeClick();
}

bool ManualProxy::bIsLongSon()
{
return Utils::judgeLoongson();
Expand Down
3 changes: 3 additions & 0 deletions src/view/manual_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ManualProxy : public QObject
void channelInit();
void searchEditTextisEmpty();
void supportBeClick();
void appStoreBeClick();
//发送页面加载完成时间
void startFinish(qint64);
void updateLabel();
Expand All @@ -32,8 +33,10 @@ public slots:
void setApplicationState(const QString &appName);
QStringList getUsedAppList();
bool hasSelperSupport();
bool hasAppStore();
void finishChannel();
void supportClick();
void appStoreClick();
bool bIsLongSon();
void showUpdateLabel();
QString appToPath(const QString &appName);
Expand Down
13 changes: 12 additions & 1 deletion src/view/web_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ void WebWindow::HelpSupportTriggered(bool bActiontrigger)
}
}

void WebWindow::appStoreTriggered()
{
if (!Utils::hasAppStore())
return;

QProcess process;
process.startDetached("deepin-home-appstore-client");
process.waitForFinished();
}

void WebWindow::slotUpdateLabel()
{
sendMessage(QIcon(":/common/images/ok.svg"), QObject::tr("The content was updated"));
Expand Down Expand Up @@ -463,7 +473,7 @@ bool WebWindow::eventFilter(QObject *watched, QEvent *event)
if (event->type() == QEvent::FontChange && watched == this) {
if (this->settings_proxy_) {
qDebug() << "eventFilter QEvent::FontChange";
auto fontInfo = this->fontInfo();
QFontInfo fontInfo = this->fontInfo();
emit this->settings_proxy_->fontChangeRequested(fontInfo.family(),
fontInfo.pixelSize());
}
Expand Down Expand Up @@ -709,6 +719,7 @@ void WebWindow::initWebView()
connect(manual_proxy_, &ManualProxy::WidgetLower, this, &WebWindow::lower);
connect(manual_proxy_, &ManualProxy::updateLabel, this, &WebWindow::slotUpdateLabel);
connect(manual_proxy_, &ManualProxy::supportBeClick, this, [this] { this->HelpSupportTriggered(); });
connect(manual_proxy_, &ManualProxy::appStoreBeClick, this, [this] { this->appStoreTriggered(); });

//web主页html路径
const QFileInfo info(kIndexPage);
Expand Down
1 change: 1 addition & 0 deletions src/view/web_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public slots:
void settingContextMenu();
QRect hasWidgetRect(QWidget *);
void HelpSupportTriggered(bool bActiontrigger = false);
void appStoreTriggered();

QString app_name_;
QString keyword_;
Expand Down
46 changes: 45 additions & 1 deletion src/web/toManual/js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ global.lastUrlBeforeSearch = '/';
global.lastHistoryIndex = 0;
global.lastAction = 'PUSH';
global.isShowHelperSupport = false;
global.isShowAppStore = false;
global.scrollBehavior = 'smooth';
global.bIsReload = false;
// global.gHistoryGo = 0;
Expand Down Expand Up @@ -67,7 +68,36 @@ const Support = ({ text }) => {
onMouseLeave={() => setIsHovered(false)}
style={{ userSelect: 'none' }}
>
<img className="support" src="./pic.svg"></img>
<img className="support" src="./support.svg"></img>
{isHovered && <div className={`tooltip-wrapper ${isHovered ? 'show' : ''}`}>{tooltipText}</div>}
</div> : <div></div>
);
};

const AppStore = ({ text }) => {
const [isHovered, setIsHovered] = useState(false);
const [tooltipText, setTooltipText] = useState(text);

useEffect(() => {
if (isHovered) {
setTooltipText(global.i18n['AppStore']);
}
}, [isHovered]);

useEffect(() => {
if (!isHovered) {
setTooltipText('');
}
}, [isHovered]);

return (
global.isShowAppStore ? <div className="store-div"
onClick={() => global.qtObjects.manual.appStoreClick()}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
style={{ userSelect: 'none' }}
>
<img className="store" src="./shop.svg"></img>
{isHovered && <div className={`tooltip-wrapper ${isHovered ? 'show' : ''}`}>{tooltipText}</div>}
</div> : <div></div>
);
Expand Down Expand Up @@ -103,6 +133,9 @@ class App extends React.Component {
global.qtObjects.manual.hasSelperSupport(bFlag => {
global.isShowHelperSupport = bFlag;
});
global.qtObjects.manual.hasAppStore(bFlag => {
global.isShowAppStore = bFlag;
});

global.qtObjects.manual.bIsLongSon(isLongSon => {
if (isLongSon) {
Expand Down Expand Up @@ -341,6 +374,11 @@ class App extends React.Component {
var pathList = pathName.split("/");
var cKeyword = '';

if (pathName.includes("common-application-libraries"))
document.documentElement.style.setProperty(`--app-store-visibility`, 'visible');
else
document.documentElement.style.setProperty(`--app-store-visibility`, 'hidden');

//search页===>/search/:keyword
//open页=====>/open/:file/:hash?/:key?
if (pathList.length == 3) {
Expand Down Expand Up @@ -540,6 +578,8 @@ class App extends React.Component {
if (toB.length == 1) toB = '0' + toB;
toRGB = "#" + toR + toG + toB;
document.documentElement.style.setProperty(`--nav-hash-press-color`, toRGB);
// toRGB = "rgba(" + pR + ", " + pG + ", " + pB + ", " + "0.4)";
// document.documentElement.style.setProperty(`--active-shadow-color`, toRGB);
}

global.setWordFontfamily = (strFontFamily) => {
Expand Down Expand Up @@ -724,6 +764,8 @@ class App extends React.Component {
this.context.router.history.goBack();
};
this.componentDidUpdate();

document.documentElement.style.setProperty(`--app-store-visibility`, 'hidden');
}
componentDidUpdate() {
if (global.qtObjects) {
Expand All @@ -749,6 +791,8 @@ class App extends React.Component {
<Route path="/search/:keyword" component={Search} />
</Switch>
)}

<AppStore text=" "></AppStore>
<Support text=" "></Support>
</div>
);
Expand Down
1 change: 0 additions & 1 deletion src/web/toManual/js/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default class Main extends Component {
}
console.log("main init==>file:", file, " hash:", hash, " key:", key);


global.hash = hash;
var filePath = file;

Expand Down
51 changes: 51 additions & 0 deletions src/web/toManual/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,55 @@ div {
visibility: visible;
}
}

.store-div {
width: 48px;
height: 48px;
border-radius: 48px;
background-color: var(--nav-hash-word-color);
display: inline-block;
position: fixed;
left: var(--support-position);
bottom: 83px;
z-index: 10;
visibility: var(--app-store-visibility);
// box-shadow: 0px 4px 6px var(--active-shadow-color);

&:hover {
cursor: pointer;
background-color: var(--nav-hash-hover-color);
}
&:active {
// background-color: blue;
background-color: var(--nav-hash-press-color);
}

.store {
position: absolute;
width: 20px;
height: 21px;
top: 14px;
left: 14px;
}

.tooltip-wrapper {
position: absolute;
visibility: hidden;
white-space: nowrap;
right: -15px;
bottom: -23px;
background-color: var(--tips-background-color);
color: var(--nav-hove-word-color);
max-width: 500px;
padding: 2px 5px;
border-radius: 8px;
border: 1px solid var(--tips-border-color);
font-family: var(--nav-world-font-family);
box-shadow: 0px 3px 20px var(--tips-shadow-color);
}

.tooltip-wrapper.show {
visibility: visible;
}
}
}
38 changes: 38 additions & 0 deletions src/web_dist/toManual/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,44 @@ div {
box-shadow: 0px 3px 20px var(--tips-shadow-color); }
div .support-div .tooltip-wrapper.show {
visibility: visible; }
div .store-div {
width: 48px;
height: 48px;
border-radius: 48px;
background-color: var(--nav-hash-word-color);
display: inline-block;
position: fixed;
left: var(--support-position);
bottom: 83px;
z-index: 10;
visibility: var(--app-store-visibility); }
div .store-div:hover {
cursor: pointer;
background-color: var(--nav-hash-hover-color); }
div .store-div:active {
background-color: var(--nav-hash-press-color); }
div .store-div .store {
position: absolute;
width: 20px;
height: 21px;
top: 14px;
left: 14px; }
div .store-div .tooltip-wrapper {
position: absolute;
visibility: hidden;
white-space: nowrap;
right: -15px;
bottom: -23px;
background-color: var(--tips-background-color);
color: var(--nav-hove-word-color);
max-width: 500px;
padding: 2px 5px;
border-radius: 8px;
border: 1px solid var(--tips-border-color);
font-family: var(--nav-world-font-family);
box-shadow: 0px 3px 20px var(--tips-shadow-color); }
div .store-div .tooltip-wrapper.show {
visibility: visible; }

@charset "UTF-8";
.Triangle, #article .t_center_down::after, #article .t_center_up::after, #article .t_right_down::after, #article .t_right_up::after, #article .t_left_down::after, #article .t_left_up::after {
Expand Down
Loading
Loading