- 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 - enhancement: suppoort localization info in project templates
- change: template / project files use utf-8 encoding instead of ANSI - change: template / project files use utf-8 encoding instead of ANSI
- fix: .rc file shouldn't be syntax checked - 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 Red Panda C++ Version 0.12.7
- change: make current build system follow FHS specifications - change: make current build system follow FHS specifications

View File

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

View File

@ -5012,6 +5012,8 @@ void MainWindow::on_actionNew_Project_triggered()
mProject->saveAll(); mProject->saveAll();
updateProjectView(); 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; 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 int Settings::UI::settingsDialogHeight() const
{ {
return mSettingsDialogHeight; return mSettingsDialogHeight;
@ -4865,6 +4885,8 @@ void Settings::UI::doSave()
saveValue("settings_dialog_width", mSettingsDialogWidth); saveValue("settings_dialog_width", mSettingsDialogWidth);
saveValue("settings_dialog_height", mSettingsDialogHeight); saveValue("settings_dialog_height", mSettingsDialogHeight);
saveValue("settings_dialog_splitter", mSettingsDialogSplitterPos); saveValue("settings_dialog_splitter", mSettingsDialogSplitterPos);
saveValue("new_project_dialog_width", mNewProjectDialogWidth);
saveValue("new_project_dialog_height", mNewProjectDialogHeight);
} }
void Settings::UI::doLoad() void Settings::UI::doLoad()
@ -4901,10 +4923,13 @@ void Settings::UI::doLoad()
mShowProblem = boolValue("show_problem",true); mShowProblem = boolValue("show_problem",true);
//dialogs //dialogs
mCPUDialogWidth = intValue("cpu_dialog_width",800*qApp->desktop()->width()/1920); mCPUDialogWidth = intValue("cpu_dialog_width",977*qApp->desktop()->width()/1920);
mCPUDialogHeight = intValue("cpu_dialog_height",600*qApp->desktop()->height()/1080); mCPUDialogHeight = intValue("cpu_dialog_height",622*qApp->desktop()->height()/1080);
mCPUDialogSplitterPos = intValue("cpu_dialog_splitter",500*qApp->desktop()->width()/1920); mCPUDialogSplitterPos = intValue("cpu_dialog_splitter",500*qApp->desktop()->width()/1920);
mSettingsDialogWidth = intValue("settings_dialog_width",800*qApp->desktop()->width()/1920); mSettingsDialogWidth = intValue("settings_dialog_width",977*qApp->desktop()->width()/1920);
mSettingsDialogHeight = intValue("settings_dialog_height",600*qApp->desktop()->height()/1080); mSettingsDialogHeight = intValue("settings_dialog_height",622*qApp->desktop()->height()/1080);
mSettingsDialogSplitterPos = intValue("settings_dialog_splitter",300*qApp->desktop()->width()/1920); 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; int settingsDialogSplitterPos() const;
void setSettingsDialogSplitterPos(int newSettingsDialogSplitterPos); void setSettingsDialogSplitterPos(int newSettingsDialogSplitterPos);
int newProjectDialogWidth() const;
void setNewProjectDialogWidth(int newNewProjectDialogWidth);
int newProjectDialogHeight() const;
void setNewProjectDialogHeight(int newNewProjectDialogHeight);
private: private:
QByteArray mMainWindowState; QByteArray mMainWindowState;
QByteArray mMainWindowGeometry; QByteArray mMainWindowGeometry;
@ -993,6 +999,8 @@ public:
int mSettingsDialogWidth; int mSettingsDialogWidth;
int mSettingsDialogHeight; int mSettingsDialogHeight;
int mSettingsDialogSplitterPos; int mSettingsDialogSplitterPos;
int mNewProjectDialogWidth;
int mNewProjectDialogHeight;
protected: protected:
void doSave() override; void doSave() override;

View File

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

View File

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

View File

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

View File

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