- enhancement: redesigned new project unit dialog
This commit is contained in:
parent
02910bbe76
commit
628b247fcb
1
NEWS.md
1
NEWS.md
|
@ -12,6 +12,7 @@ Red Panda C++ Version 1.0.3
|
||||||
- change: don't auto jump to the first syntax error location when compile
|
- change: don't auto jump to the first syntax error location when compile
|
||||||
- enhancement: don't show folders that doesn't contain files in the project view
|
- enhancement: don't show folders that doesn't contain files in the project view
|
||||||
- enhancement: redesigned new project unit dialog
|
- enhancement: redesigned new project unit dialog
|
||||||
|
- fix: some dialog's icon not correctly set
|
||||||
|
|
||||||
Red Panda C++ Version 1.0.2
|
Red Panda C++ Version 1.0.2
|
||||||
- enhancement: press tab in column mode won't exit column mode
|
- enhancement: press tab in column mode won't exit column mode
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5946,10 +5946,12 @@ void MainWindow::newProjectUnitFile()
|
||||||
QString newFileName;
|
QString newFileName;
|
||||||
PProjectUnit newUnit;
|
PProjectUnit newUnit;
|
||||||
if (mProject->modelType() == ProjectModelType::FileSystem) {
|
if (mProject->modelType() == ProjectModelType::FileSystem) {
|
||||||
|
PProjectModelNode modelTypeNode = pNode;
|
||||||
|
while (modelTypeNode && modelTypeNode->folderNodeType==ProjectSpecialFolderNode::NonSpecial) {
|
||||||
|
modelTypeNode=modelTypeNode->parent.lock();
|
||||||
|
}
|
||||||
NewProjectUnitDialog newProjectUnitDialog;
|
NewProjectUnitDialog newProjectUnitDialog;
|
||||||
QString folder = mProject->fileSystemNodeFolderPath(pNode);
|
switch (modelTypeNode->folderNodeType) {
|
||||||
newProjectUnitDialog.setFolder(folder);
|
|
||||||
switch (pNode->folderNodeType) {
|
|
||||||
case ProjectSpecialFolderNode::HEADERS:
|
case ProjectSpecialFolderNode::HEADERS:
|
||||||
newProjectUnitDialog.setSuffix("h");
|
newProjectUnitDialog.setSuffix("h");
|
||||||
break;
|
break;
|
||||||
|
@ -5962,13 +5964,23 @@ void MainWindow::newProjectUnitFile()
|
||||||
default:
|
default:
|
||||||
newProjectUnitDialog.setSuffix("");
|
newProjectUnitDialog.setSuffix("");
|
||||||
}
|
}
|
||||||
|
QString folder = mProject->fileSystemNodeFolderPath(pNode);
|
||||||
|
qDebug()<<folder;
|
||||||
|
newProjectUnitDialog.setFolder(folder);
|
||||||
if (newProjectUnitDialog.exec()!=QDialog::Accepted) {
|
if (newProjectUnitDialog.exec()!=QDialog::Accepted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newFileName=newProjectUnitDialog.filename();
|
newFileName=QDir(newProjectUnitDialog.folder()).absoluteFilePath(newProjectUnitDialog.filename());
|
||||||
if (newFileName.isEmpty())
|
if (newFileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
do {
|
||||||
|
newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
|
||||||
|
if (mProject->options().isCpp)
|
||||||
|
newFileName += ".cpp";
|
||||||
|
else
|
||||||
|
newFileName += ".c";
|
||||||
|
} while (QDir(mProject->directory()).exists(newFileName));
|
||||||
newFileName = QInputDialog::getText(
|
newFileName = QInputDialog::getText(
|
||||||
this,
|
this,
|
||||||
tr("New Project File Name"),
|
tr("New Project File Name"),
|
||||||
|
@ -5977,11 +5989,12 @@ void MainWindow::newProjectUnitFile()
|
||||||
newFileName);
|
newFileName);
|
||||||
if (newFileName.isEmpty())
|
if (newFileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
|
newFileName = QDir(mProject->directory()).absoluteFilePath(newFileName);
|
||||||
QMessageBox::critical(this,tr("File Already Exists!"),
|
}
|
||||||
tr("File '%1' already exists!").arg(newFileName));
|
if (fileExists(newFileName)) {
|
||||||
return;
|
QMessageBox::critical(this,tr("File Already Exists!"),
|
||||||
}
|
tr("File '%1' already exists!").arg(newFileName));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
newUnit = mProject->newUnit(
|
newUnit = mProject->newUnit(
|
||||||
pNode,newFileName);
|
pNode,newFileName);
|
||||||
|
|
|
@ -1695,6 +1695,18 @@ QFileSystemWatcher *Project::fileSystemWatcher() const
|
||||||
return mFileSystemWatcher;
|
return mFileSystemWatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Project::fileSystemNodeFolderPath(const PProjectModelNode &node)
|
||||||
|
{
|
||||||
|
QString result;
|
||||||
|
PProjectModelNode pNode = node;
|
||||||
|
while (pNode && pNode->folderNodeType == ProjectSpecialFolderNode::NonSpecial) {
|
||||||
|
result = node->text + "/" +result;
|
||||||
|
pNode = pNode->parent.lock();
|
||||||
|
}
|
||||||
|
result = folder() + "/" + result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
EditorList *Project::editorList() const
|
EditorList *Project::editorList() const
|
||||||
{
|
{
|
||||||
return mEditorList;
|
return mEditorList;
|
||||||
|
|
|
@ -237,6 +237,8 @@ public:
|
||||||
|
|
||||||
QFileSystemWatcher *fileSystemWatcher() const;
|
QFileSystemWatcher *fileSystemWatcher() const;
|
||||||
|
|
||||||
|
QString fileSystemNodeFolderPath(const PProjectModelNode& node);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nodesChanged();
|
void nodesChanged();
|
||||||
void modifyChanged(bool value);
|
void modifyChanged(bool value);
|
||||||
|
|
|
@ -31,7 +31,7 @@ void NewProjectUnitDialog::setFolder(const QString &folderName)
|
||||||
if (folderName!=folder()) {
|
if (folderName!=folder()) {
|
||||||
ui->txtFolder->setText(folderName);
|
ui->txtFolder->setText(folderName);
|
||||||
QDir dir(folder());
|
QDir dir(folder());
|
||||||
if (dir.exists(filename()) || filename().isEmpty()) {
|
if (filename().isEmpty() || dir.exists(filename())) {
|
||||||
//todo change filename
|
//todo change filename
|
||||||
QString newFileName;
|
QString newFileName;
|
||||||
QString ext;
|
QString ext;
|
||||||
|
@ -50,6 +50,16 @@ void NewProjectUnitDialog::setFolder(const QString &folderName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString NewProjectUnitDialog::filename() const
|
||||||
|
{
|
||||||
|
return ui->txtFilename->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewProjectUnitDialog::setFilename(const QString &filename)
|
||||||
|
{
|
||||||
|
ui->txtFilename->setText(filename);
|
||||||
|
}
|
||||||
|
|
||||||
void NewProjectUnitDialog::onUpdateIcons()
|
void NewProjectUnitDialog::onUpdateIcons()
|
||||||
{
|
{
|
||||||
pIconsManager->setIcon(ui->btnBrowse, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
pIconsManager->setIcon(ui->btnBrowse, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
||||||
|
@ -90,21 +100,20 @@ void NewProjectUnitDialog::updateBtnOkStatus()
|
||||||
&& QFileInfo(ui->txtFolder->text()).isDir());
|
&& QFileInfo(ui->txtFolder->text()).isDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProjectUnitDialog::closeEvent(QCloseEvent *event)
|
const QString &NewProjectUnitDialog::suffix() const
|
||||||
{
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NewProjectUnitDialog::suffix() const
|
|
||||||
{
|
{
|
||||||
return mSuffix;
|
return mSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProjectUnitDialog::setSuffix(bool newSuffix)
|
void NewProjectUnitDialog::setSuffix(const QString &newSuffix)
|
||||||
{
|
{
|
||||||
mSuffix = newSuffix;
|
mSuffix = newSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewProjectUnitDialog::closeEvent(QCloseEvent */*event*/)
|
||||||
|
{
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
|
||||||
void NewProjectUnitDialog::on_txtFolder_textChanged(const QString &/*arg1*/)
|
void NewProjectUnitDialog::on_txtFolder_textChanged(const QString &/*arg1*/)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,8 +21,8 @@ public:
|
||||||
QString filename() const;
|
QString filename() const;
|
||||||
void setFilename(const QString& filename);
|
void setFilename(const QString& filename);
|
||||||
|
|
||||||
bool suffix() const;
|
const QString &suffix() const;
|
||||||
void setSuffix(bool newSuffix);
|
void setSuffix(const QString &newSuffix);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onUpdateIcons();
|
void onUpdateIcons();
|
||||||
|
@ -40,7 +40,7 @@ private:
|
||||||
private:
|
private:
|
||||||
Ui::NewProjectUnitDialog *ui;
|
Ui::NewProjectUnitDialog *ui;
|
||||||
private:
|
private:
|
||||||
bool mSuffix;
|
QString mSuffix;
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>547</width>
|
||||||
<height>300</height>
|
<height>250</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>New Project Unit</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
|
Loading…
Reference in New Issue