- enhancement: auto save/restore size of the new project dialog

This commit is contained in:
Roy Qu 2022-01-08 21:23:20 +08:00
parent 7a22bacd0c
commit 9775ab6c84
9 changed files with 87 additions and 8 deletions

View File

@ -2,6 +2,7 @@ Red Panda C++ Version 0.13.1
- enhancement: suppoort localization info in project templates
- change: template / project files use utf-8 encoding instead of ANSI
- fix: .rc file shouldn't be syntax checked
- enhancement: auto save/restore size of the new project dialog
Red Panda C++ Version 0.12.7
- change: make current build system follow FHS specifications

View File

@ -13,7 +13,7 @@ isEmpty(PREFIX) {
PREFIX = /usr/local
}
APP_VERSION = beta.0.12.8
APP_VERSION = beta.0.13.1
DEFINES += PREFIX=\\\"$${PREFIX}\\\"
DEFINES += APP_NAME=\\\"$${APP_NAME}\\\"

View File

@ -5012,6 +5012,8 @@ void MainWindow::on_actionNew_Project_triggered()
mProject->saveAll();
updateProjectView();
}
pSettings->ui().setNewProjectDialogWidth(dialog.width());
pSettings->ui().setNewProjectDialogHeight(dialog.height());
}

View File

@ -4605,6 +4605,26 @@ void Settings::UI::setSettingsDialogSplitterPos(int newSettingsDialogSplitterPos
mSettingsDialogSplitterPos = newSettingsDialogSplitterPos;
}
int Settings::UI::newProjectDialogWidth() const
{
return mNewProjectDialogWidth;
}
void Settings::UI::setNewProjectDialogWidth(int newNewProjectDialogWidth)
{
mNewProjectDialogWidth = newNewProjectDialogWidth;
}
int Settings::UI::newProjectDialogHeight() const
{
return mNewProjectDialogHeight;
}
void Settings::UI::setNewProjectDialogHeight(int newNewProjectDialogHeight)
{
mNewProjectDialogHeight = newNewProjectDialogHeight;
}
int Settings::UI::settingsDialogHeight() const
{
return mSettingsDialogHeight;
@ -4865,6 +4885,8 @@ void Settings::UI::doSave()
saveValue("settings_dialog_width", mSettingsDialogWidth);
saveValue("settings_dialog_height", mSettingsDialogHeight);
saveValue("settings_dialog_splitter", mSettingsDialogSplitterPos);
saveValue("new_project_dialog_width", mNewProjectDialogWidth);
saveValue("new_project_dialog_height", mNewProjectDialogHeight);
}
void Settings::UI::doLoad()
@ -4901,10 +4923,13 @@ void Settings::UI::doLoad()
mShowProblem = boolValue("show_problem",true);
//dialogs
mCPUDialogWidth = intValue("cpu_dialog_width",800*qApp->desktop()->width()/1920);
mCPUDialogHeight = intValue("cpu_dialog_height",600*qApp->desktop()->height()/1080);
mCPUDialogWidth = intValue("cpu_dialog_width",977*qApp->desktop()->width()/1920);
mCPUDialogHeight = intValue("cpu_dialog_height",622*qApp->desktop()->height()/1080);
mCPUDialogSplitterPos = intValue("cpu_dialog_splitter",500*qApp->desktop()->width()/1920);
mSettingsDialogWidth = intValue("settings_dialog_width",800*qApp->desktop()->width()/1920);
mSettingsDialogHeight = intValue("settings_dialog_height",600*qApp->desktop()->height()/1080);
mSettingsDialogWidth = intValue("settings_dialog_width",977*qApp->desktop()->width()/1920);
mSettingsDialogHeight = intValue("settings_dialog_height",622*qApp->desktop()->height()/1080);
mSettingsDialogSplitterPos = intValue("settings_dialog_splitter",300*qApp->desktop()->width()/1920);
mNewProjectDialogWidth = intValue("new_project_dialog_width", 900*qApp->desktop()->width()/1920);
mNewProjectDialogHeight = intValue("new_project_dialog_height", 600*qApp->desktop()->height()/1080);
}

View File

@ -954,6 +954,12 @@ public:
int settingsDialogSplitterPos() const;
void setSettingsDialogSplitterPos(int newSettingsDialogSplitterPos);
int newProjectDialogWidth() const;
void setNewProjectDialogWidth(int newNewProjectDialogWidth);
int newProjectDialogHeight() const;
void setNewProjectDialogHeight(int newNewProjectDialogHeight);
private:
QByteArray mMainWindowState;
QByteArray mMainWindowGeometry;
@ -993,6 +999,8 @@ public:
int mSettingsDialogWidth;
int mSettingsDialogHeight;
int mSettingsDialogSplitterPos;
int mNewProjectDialogWidth;
int mNewProjectDialogHeight;
protected:
void doSave() override;

View File

@ -22,6 +22,7 @@
#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QPainter>
#include <QPushButton>
NewProjectDialog::NewProjectDialog(QWidget *parent) :
@ -46,6 +47,7 @@ NewProjectDialog::NewProjectDialog(QWidget *parent) :
}
ui->txtProjectName->setText(projectName);
ui->txtLocation->setText(location);
resize(pSettings->ui().newProjectDialogWidth(),pSettings->ui().newProjectDialogHeight());
connect(mTemplatesTabBar,
&QTabBar::currentChanged,
@ -162,7 +164,7 @@ void NewProjectDialog::updateView()
if (category == tabText) {
QListWidgetItem * item;
QString iconFilename = QDir(pSettings->dirs().templateDir()).absoluteFilePath(t->icon());
QIcon icon(iconFilename);
QIcon icon=QIcon(iconFilename);
if (icon.isNull()) {
//todo : use an default icon
item = new QListWidgetItem(
@ -173,6 +175,8 @@ void NewProjectDialog::updateView()
icon,
t->name());
}
item->setSizeHint(QSize(font().pixelSize()*6,font().pixelSize()*2+64));
item->setTextAlignment(Qt::AlignHCenter | Qt::AlignTop);
item->setData(Qt::ToolTipRole,t->name());
item->setData(Qt::UserRole,i);
ui->lstTemplates->addItem(item);

View File

@ -19,6 +19,12 @@
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="spacing">
<number>10</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
@ -36,6 +42,18 @@
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lblDescription">
<property name="sizePolicy">
@ -47,6 +65,15 @@
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -91,6 +118,18 @@
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QLineEdit" name="txtLocation"/>
</item>

View File

@ -1,7 +1,7 @@
[Template]
ver=2
Name=Windows Application
Name[zh_CN]=Windows应用程序
Name[zh_CN]=Windows程序
Icon=Windows.ico
Description=A standard Windows application
Description[zh_CN]=基于Windows API开发的图形界面应用程序

View File

@ -1,7 +1,7 @@
[Template]
ver=2
Name=Single Dialog Application
Name[zh_CN]=单对话框应用程序
Name[zh_CN]=单对话框程序
Icon=Single Dialog Application.ico
Description=An Appliction use a dialog as the main UI
Description[zh_CN]=使用一个对话框作为主用户界面简单程序