add icon and new workspace

This commit is contained in:
jiegeaiai 2025-01-04 23:41:53 +08:00
parent f4b93f7278
commit ff462c7bd9
10 changed files with 93 additions and 33 deletions

View File

@ -19,7 +19,7 @@ FILE(GLOB_RECURSE CPP_FILES ./*.cpp common/*.cpp model/*.cpp app/*.cpp)
FILE(GLOB_RECURSE CC_FILES ./*.cc)
FILE(GLOB_RECURSE UI_FILES ./*.ui)
FILE(GLOB_RECURSE QRC_FILES ./*.qrc)
FILE(GLOB_RECURSE RC_FILES res/*.rc)
FILE(GLOB_RECURSE RC_FILES ./res/*.rc)
SET(
TS_FILES

View File

@ -0,0 +1 @@
IDI_ICON ICON DISCARDABLE ".\\res\\sys_icon.ico"

BIN
src/res/sys_icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1704,43 +1704,47 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="29"/>
<source>1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="40"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="43"/>
<source>Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="47"/>
<source>d:/hysw</source>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="32"/>
<source>input workspace name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="57"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="56"/>
<source>select workspace save path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="63"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="68"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="74"/>
<source>describe</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="95"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="101"/>
<source>Sure</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="102"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.ui" line="108"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="49"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="55"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="64"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="79"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="88"/>
<source>warning</source>
<translation type="unfinished"></translation>
</message>
@ -1750,12 +1754,32 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="55"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
<source>current path is contains current folder, do you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="64"/>
<source>removeRecursively failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
<source>mkpath failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="79"/>
<source>name is exits</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="70"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="88"/>
<source>create workSpace failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="98"/>
<source>save spaceWork directory</source>
<translation type="unfinished"></translation>
</message>

View File

@ -50,6 +50,30 @@ void WorkSpaceDlg::OnSure() {
return;
}
QString workspacePath = QString("%1/%2").arg(savePath).arg(name);
QDir dir(workspacePath);
if (dir.exists()) {
LOG_WARN("current path is contains current folder, {}", workspacePath.toStdString());
if (QMessageBox::warning(this, tr("warning"), tr("current path is contains current folder, do you want to overwrite it?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
return;
}
if (!dir.removeRecursively()) {
LOG_WARN("removeRecursively {} failed", workspacePath.toStdString());
QMessageBox::warning(this, tr("warning"), tr("removeRecursively failed"));
return;
}
WorkSpaceManager::Get().Remove(name);
}
if (!dir.mkpath(workspacePath)) {
LOG_WARN("mkpath {} failed", workspacePath.toStdString());
QMessageBox::warning(this, tr("warning"), tr("mkpath failed"));
return;
}
if (WorkSpaceManager::Get().Contains(name)) {
LOG_WARN("name is exits");
QMessageBox::warning(this, tr("warning"), tr("name is exits"));
@ -58,10 +82,14 @@ void WorkSpaceDlg::OnSure() {
WorkSpace* workSpace = WorkSpaceManager::Get().GetOrCreate(name);
workSpace->SetDescribe(ui->etDescribe->toPlainText());
//workSpace->Save(savePath);
workspacePath += QString("/%1.dyt").arg(name);
if (!workSpace->Save(workspacePath)) {
LOG_ERROR("save workSpace failed");
QMessageBox::warning(this, tr("warning"), tr("create workSpace failed"));
return;
}
emit WorkSpaceManager::Get().WorkSpaceChanged(workSpace);
workSpace->BuildDefault();
accept();
}

View File

@ -26,7 +26,10 @@
<item>
<widget class="QLineEdit" name="leName">
<property name="text">
<string>1</string>
<string/>
</property>
<property name="placeholderText">
<string>input workspace name</string>
</property>
</widget>
</item>
@ -44,11 +47,14 @@
<item>
<widget class="QLineEdit" name="lePath">
<property name="text">
<string>d:/hysw</string>
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>select workspace save path</string>
</property>
</widget>
</item>
<item>

View File

@ -157,18 +157,6 @@ bool WorkSpace::Save() {
return xmlWrite.Save(path_);
}
bool WorkSpace::BuildDefault() {
/* WorkSpaceItemGroup* item = new WorkSpaceItemGroup("root", this);
AddItem(item, nullptr);
WorkSpaceItemGroup* subItem = new WorkSpaceRiverGroup(tr("River0"));
AddItem(subItem, item);
item = subItem;
subItem = new WorkSpaceRiverNetGroup(tr("RiverNet0"));
AddItem(subItem, item);*/
return true;
}
bool WorkSpace::Load(const QString& dyt) {
WorkSpaceXMLParse parse(this);
bool success = parse.Load(dyt);

View File

@ -70,7 +70,6 @@ public:
bool Save(const QString& path);
bool Save();
bool BuildDefault();
bool Load(const QString& dyt);
void Unlaod();

View File

@ -28,6 +28,19 @@ bool WorkSpaceManager::Contains(const QString& name) const {
return false;
}
bool WorkSpaceManager::Remove(const QString& name) {
auto itor = workSpaces_.find(name);
if (workSpaces_.end() == itor) {
return true;
}
WorkSpace* workspace = itor->second;
if (nullptr != workspace) {
workspace->deleteLater();
}
workSpaces_.erase(itor);
}
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt, class OsgView* view) {
WorkSpace* workspace = new WorkSpace(view, this);
if (!workspace->Load(dyt)) {

View File

@ -20,6 +20,7 @@ public:
void OnDestory();
bool Contains(const QString& name) const;
bool Remove(const QString& name);
WorkSpace* LoadDyt(const QString& dyt, class OsgView* view);
WorkSpace* GetOrCreate(const QString& path);
void SetCurrent(WorkSpace* workspace);