#I9JAAC 【次要】【主题制作工坊】字体最大化后,保存路径界面显示不全
This commit is contained in:
parent
634b1a617c
commit
c7f05f4c7c
|
@ -31,7 +31,12 @@ SavePathDialog::SavePathDialog(QWidget *parent) :
|
|||
QGridLayout *layout = new QGridLayout(mainwindow);
|
||||
m_pathLabel = new QLabel;
|
||||
QString path = getSavePath();
|
||||
m_pathLabel->setText(tr("Storage Path:")+path);
|
||||
QString showpath = tr("Storage Path:")+path;
|
||||
QFont f(m_pathLabel->font());//获取控件字体font
|
||||
QFontMetrics fm(f);
|
||||
QString str1= fm.elidedText(showpath, Qt::ElideRight, 250);//三个参数分别为:需要省略的字符串,省略方式,长度
|
||||
|
||||
m_pathLabel->setText(str1);
|
||||
m_pathLabel->setToolTip(path);
|
||||
m_modifyBtn = new QPushButton;
|
||||
m_modifyBtn->setFixedSize(QSize(88,33));
|
||||
|
@ -51,12 +56,14 @@ SavePathDialog::SavePathDialog(QWidget *parent) :
|
|||
emit savePathUpdate(m_savepath);
|
||||
this->close();
|
||||
});
|
||||
}
|
||||
|
||||
void SavePathDialog::updateLabel(QString savepath)
|
||||
{
|
||||
m_pathLabel->setText(tr("Storage Path:")+savepath);
|
||||
m_pathLabel->setToolTip(savepath);
|
||||
if (QGSettings::isSchemaInstalled("org.ukui.style")) {
|
||||
QGSettings *gSetting = new QGSettings("org.ukui.style", QByteArray(), this);
|
||||
connect(gSetting, &QGSettings::changed, this, [=](const QString &key) {
|
||||
if ("systemFontSize" == key) {
|
||||
updateLabelShow(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
QString SavePathDialog::getSavePath()
|
||||
|
@ -77,13 +84,25 @@ QString SavePathDialog::getSavePath()
|
|||
}
|
||||
}
|
||||
|
||||
void SavePathDialog::updateLabelShow(QString savepath)
|
||||
{
|
||||
QString path = savepath;
|
||||
QString showpath = tr("Storage Path:")+path;
|
||||
QFont f(m_pathLabel->font());
|
||||
QFontMetrics fm(f);
|
||||
QString str1= fm.elidedText(showpath, Qt::ElideRight, 250);
|
||||
|
||||
m_pathLabel->setText(str1);
|
||||
m_pathLabel->setToolTip(path);
|
||||
}
|
||||
|
||||
void SavePathDialog::onModifyBtnClicked()
|
||||
{
|
||||
QString newFilePath = QFileDialog::getExistingDirectory(this, tr("Select Directory"),QDir::homePath());
|
||||
if(newFilePath != nullptr){
|
||||
m_savepath = newFilePath;
|
||||
this->updateLabel(newFilePath);
|
||||
m_confirmBtn->setEnabled(true);
|
||||
updateLabelShow(newFilePath);
|
||||
}else{
|
||||
qDebug()<<"savepath is null";
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ class SavePathDialog : public kdk::KDialog
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit SavePathDialog(QWidget *parent = nullptr);
|
||||
void updateLabel(QString savepath);
|
||||
QString getSavePath();
|
||||
void updateLabelShow(QString savepath);
|
||||
signals:
|
||||
void savePathUpdate(const QString& filePath);
|
||||
public slots:
|
||||
|
|
Loading…
Reference in New Issue