Commit ee8bfccd authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Port SingleFileResource Config UI to QFormLayout

parent d49354dd
Pipeline #68821 failed with stage
in 23 minutes and 50 seconds
......@@ -12,8 +12,8 @@
</property>
<property name="minimumSize">
<size>
<width>900</width>
<height>0</height>
<width>450</width>
<height>350</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_2">
......@@ -40,143 +40,111 @@
</attribute>
<layout class="QVBoxLayout" name="tabLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Filename</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Filename:</string>
</property>
<property name="buddy">
<cstring>kcfg_Path</cstring>
</property>
</widget>
</item>
<item>
<widget class="KUrlRequester" name="kcfg_Path"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="textEdit">
<property name="text">
<string>Select the file whose contents should be represented by this resource. If the file does not exist, it will be created. A URL of a remote file can also be specified, but note that monitoring for file changes will not work in this case.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Display Name</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_1">
<property name="text">
<string>&amp;Name:</string>
</property>
<property name="buddy">
<cstring>kcfg_DisplayName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="kcfg_DisplayName"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="textEdit_2">
<property name="text">
<string>Enter the name used to identify this resource in displays. If not specified, the filename will be used.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="filenameLabel">
<property name="text">
<string>Filename:</string>
</property>
<property name="buddy">
<cstring>kcfg_Path</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KUrlRequester" name="kcfg_Path"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="pathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select the file whose contents should be represented by this resource. If the file does not exist, it will be created. A URL of a remote file can also be specified, but note that monitoring for file changes will not work in this case.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>kcfg_Path</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="filenameLabel">
<property name="text">
<string>Display Name:</string>
</property>
<property name="buddy">
<cstring>kcfg_DisplayName</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="kcfg_DisplayName"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="kcfg_ReadOnly">
<property name="text">
<string>Read only</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="readOnlyLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="visible">
<bool>true</bool>
</property>
<property name="text">
<string>If read-only mode is enabled, no changes will be written to the file selected above. Read-only mode will be automatically enabled if you do not have write access to the file or the file is on a remote server that does not support write access.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>kcfg_ReadOnly</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="kcfg_MonitorFile">
<property name="text">
<string>Enable file &amp;monitoring</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="monitoringLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>If file monitoring is enabled the resource will reload the file when changes are made by other programs. It also tries to create a backup in case of conflicts whenever possible.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>kcfg_MonitorFile</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Access Rights</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="textEdit_3">
<property name="text">
<string>If read-only mode is enabled, no changes will be written to the file selected above. Read-only mode will be automatically enabled if you do not have write access to the file or the file is on a remote server that does not support write access.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_ReadOnly">
<property name="text">
<string>Read only</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_MonitorFile">
<property name="title">
<string>Monitoring</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_MonitorFile">
<property name="text">
<string>Enable file &amp;monitoring</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="textEdit_4">
<property name="text">
<string>If file monitoring is enabled the resource will reload the file when changes are made by other programs. It also tries to create a backup in case of conflicts whenever possible.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="KMessageWidget" name="statusLabel"/>
</item>
</layout>
</widget>
......@@ -190,6 +158,11 @@
<extends>QWidget</extends>
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
<header>kmessagewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -15,6 +15,7 @@
#include <KLocalizedString>
#include <KSharedConfig>
#include <QFontDatabase>
#include <QPushButton>
#include <QTabBar>
#include <QVBoxLayout>
......@@ -30,7 +31,7 @@ SingleFileResourceConfigWidgetBase::SingleFileResourceConfigWidgetBase(QWidget *
mainLayout->setContentsMargins(0, 0, 0, 0);
ui.setupUi(mainWidget);
ui.kcfg_Path->setMode(KFile::File);
ui.statusLabel->setText(QString());
ui.statusLabel->setVisible(false);
ui.tabWidget->tabBar()->hide();
......@@ -38,6 +39,10 @@ SingleFileResourceConfigWidgetBase::SingleFileResourceConfigWidgetBase(QWidget *
connect(ui.kcfg_MonitorFile, &QCheckBox::toggled, this, &SingleFileResourceConfigWidgetBase::validate);
ui.kcfg_Path->setFocus();
QTimer::singleShot(0, this, &SingleFileResourceConfigWidgetBase::validate);
ui.readOnlyLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
ui.monitoringLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
ui.pathLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
}
SingleFileResourceConfigWidgetBase::~SingleFileResourceConfigWidgetBase()
......@@ -60,7 +65,7 @@ void SingleFileResourceConfigWidgetBase::setFilter(const QString &filter)
void SingleFileResourceConfigWidgetBase::setMonitorEnabled(bool enable)
{
mMonitorEnabled = enable;
ui.groupBox_MonitorFile->setVisible(mMonitorEnabled);
ui.kcfg_MonitorFile->setEnabled(mMonitorEnabled);
}
void SingleFileResourceConfigWidgetBase::setUrl(const QUrl &url)
......@@ -104,7 +109,7 @@ void SingleFileResourceConfigWidgetBase::validate()
if (mMonitorEnabled) {
ui.kcfg_MonitorFile->setEnabled(true);
}
ui.statusLabel->setText(QString());
ui.statusLabel->setVisible(false);
// The read-only checkbox used to be disabled if the file is read-only,
// but it is then impossible to know at a later date if the file
......@@ -121,6 +126,7 @@ void SingleFileResourceConfigWidgetBase::validate()
ui.kcfg_MonitorFile->setEnabled(false);
}
ui.statusLabel->setText(i18nc("@info:status", "Checking file information..."));
ui.statusLabel->setVisible(true);
if (mStatJob) {
mStatJob->kill();
......@@ -153,14 +159,14 @@ void SingleFileResourceConfigWidgetBase::slotStatJobResult(KJob *job)
} else if (job->error()) {
// It doesn't seem possible to read nor write from the location so leave the
// ok button disabled
ui.statusLabel->setText(QString());
ui.statusLabel->setVisible(false);
Q_EMIT okEnabled(false);
mDirUrlChecked = false;
mStatJob = nullptr;
return;
}
ui.statusLabel->setText(QString());
ui.statusLabel->setVisible(false);
Q_EMIT okEnabled(true);
mDirUrlChecked = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment