- 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
|
||||
- enhancement: don't show folders that doesn't contain files in the project view
|
||||
- enhancement: redesigned new project unit dialog
|
||||
- fix: some dialog's icon not correctly set
|
||||
|
||||
Red Panda C++ Version 1.0.2
|
||||
- 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;
|
||||
PProjectUnit newUnit;
|
||||
if (mProject->modelType() == ProjectModelType::FileSystem) {
|
||||
PProjectModelNode modelTypeNode = pNode;
|
||||
while (modelTypeNode && modelTypeNode->folderNodeType==ProjectSpecialFolderNode::NonSpecial) {
|
||||
modelTypeNode=modelTypeNode->parent.lock();
|
||||
}
|
||||
NewProjectUnitDialog newProjectUnitDialog;
|
||||
QString folder = mProject->fileSystemNodeFolderPath(pNode);
|
||||
newProjectUnitDialog.setFolder(folder);
|
||||
switch (pNode->folderNodeType) {
|
||||
switch (modelTypeNode->folderNodeType) {
|
||||
case ProjectSpecialFolderNode::HEADERS:
|
||||
newProjectUnitDialog.setSuffix("h");
|
||||
break;
|
||||
|
@ -5962,13 +5964,23 @@ void MainWindow::newProjectUnitFile()
|
|||
default:
|
||||
newProjectUnitDialog.setSuffix("");
|
||||
}
|
||||
QString folder = mProject->fileSystemNodeFolderPath(pNode);
|
||||
qDebug()<<folder;
|
||||
newProjectUnitDialog.setFolder(folder);
|
||||
if (newProjectUnitDialog.exec()!=QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
newFileName=newProjectUnitDialog.filename();
|
||||
newFileName=QDir(newProjectUnitDialog.folder()).absoluteFilePath(newProjectUnitDialog.filename());
|
||||
if (newFileName.isEmpty())
|
||||
return;
|
||||
} 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(
|
||||
this,
|
||||
tr("New Project File Name"),
|
||||
|
@ -5977,12 +5989,13 @@ void MainWindow::newProjectUnitFile()
|
|||
newFileName);
|
||||
if (newFileName.isEmpty())
|
||||
return;
|
||||
if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
|
||||
newFileName = QDir(mProject->directory()).absoluteFilePath(newFileName);
|
||||
}
|
||||
if (fileExists(newFileName)) {
|
||||
QMessageBox::critical(this,tr("File Already Exists!"),
|
||||
tr("File '%1' already exists!").arg(newFileName));
|
||||
return;
|
||||
}
|
||||
}
|
||||
newUnit = mProject->newUnit(
|
||||
pNode,newFileName);
|
||||
|
||||
|
|
|
@ -1695,6 +1695,18 @@ QFileSystemWatcher *Project::fileSystemWatcher() const
|
|||
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
|
||||
{
|
||||
return mEditorList;
|
||||
|
|
|
@ -237,6 +237,8 @@ public:
|
|||
|
||||
QFileSystemWatcher *fileSystemWatcher() const;
|
||||
|
||||
QString fileSystemNodeFolderPath(const PProjectModelNode& node);
|
||||
|
||||
signals:
|
||||
void nodesChanged();
|
||||
void modifyChanged(bool value);
|
||||
|
|
|
@ -31,7 +31,7 @@ void NewProjectUnitDialog::setFolder(const QString &folderName)
|
|||
if (folderName!=folder()) {
|
||||
ui->txtFolder->setText(folderName);
|
||||
QDir dir(folder());
|
||||
if (dir.exists(filename()) || filename().isEmpty()) {
|
||||
if (filename().isEmpty() || dir.exists(filename())) {
|
||||
//todo change filename
|
||||
QString newFileName;
|
||||
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()
|
||||
{
|
||||
pIconsManager->setIcon(ui->btnBrowse, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
||||
|
@ -90,21 +100,20 @@ void NewProjectUnitDialog::updateBtnOkStatus()
|
|||
&& QFileInfo(ui->txtFolder->text()).isDir());
|
||||
}
|
||||
|
||||
void NewProjectUnitDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
bool NewProjectUnitDialog::suffix() const
|
||||
const QString &NewProjectUnitDialog::suffix() const
|
||||
{
|
||||
return mSuffix;
|
||||
}
|
||||
|
||||
void NewProjectUnitDialog::setSuffix(bool newSuffix)
|
||||
void NewProjectUnitDialog::setSuffix(const QString &newSuffix)
|
||||
{
|
||||
mSuffix = newSuffix;
|
||||
}
|
||||
|
||||
void NewProjectUnitDialog::closeEvent(QCloseEvent */*event*/)
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void NewProjectUnitDialog::on_txtFolder_textChanged(const QString &/*arg1*/)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,8 @@ public:
|
|||
QString filename() const;
|
||||
void setFilename(const QString& filename);
|
||||
|
||||
bool suffix() const;
|
||||
void setSuffix(bool newSuffix);
|
||||
const QString &suffix() const;
|
||||
void setSuffix(const QString &newSuffix);
|
||||
|
||||
private slots:
|
||||
void onUpdateIcons();
|
||||
|
@ -40,7 +40,7 @@ private:
|
|||
private:
|
||||
Ui::NewProjectUnitDialog *ui;
|
||||
private:
|
||||
bool mSuffix;
|
||||
QString mSuffix;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>547</width>
|
||||
<height>250</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>New Project Unit</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
|
|
Loading…
Reference in New Issue