mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kdirshare: implement getter for the server address and show it on label
requires b3ed6f356afe76d289a7b89d3c95b4dcfb895cbb from kdelibs Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
a693e41a4a
commit
1618f83ab3
7 changed files with 68 additions and 16 deletions
|
@ -61,10 +61,12 @@ KDirSharePlugin::KDirSharePlugin(QObject *parent, const QList<QVariant> &args)
|
|||
m_ui.sharebox->setChecked(false);
|
||||
m_ui.portgroup->setEnabled(false);
|
||||
m_ui.authgroup->setEnabled(false);
|
||||
m_ui.serverlabel->setVisible(false);
|
||||
} else {
|
||||
m_ui.sharebox->setChecked(kdirsharereply.value());
|
||||
m_ui.portgroup->setEnabled(kdirsharereply.value());
|
||||
m_ui.authgroup->setEnabled(kdirsharereply.value());
|
||||
m_ui.serverlabel->setVisible(true);
|
||||
}
|
||||
|
||||
QDBusReply<quint16> kdirsharereply2 = m_kdirshareiface.call("getPortMin", m_url);
|
||||
|
@ -106,6 +108,8 @@ KDirSharePlugin::KDirSharePlugin(QObject *parent, const QList<QVariant> &args)
|
|||
}
|
||||
m_ui.useredit->setEnabled(m_ui.authbox->isChecked());
|
||||
m_ui.passwordedit->setEnabled(m_ui.authbox->isChecked());
|
||||
|
||||
updateServerLabel();
|
||||
} else {
|
||||
kWarning() << "kdirshare module interface is not valid";
|
||||
m_ui.sharebox->setEnabled(false);
|
||||
|
@ -162,6 +166,7 @@ void KDirSharePlugin::slotShare(const bool value)
|
|||
// qDebug() << Q_FUNC_INFO << value;
|
||||
m_ui.portgroup->setEnabled(value);
|
||||
m_ui.authgroup->setEnabled(value);
|
||||
updateServerLabel();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
|
@ -217,4 +222,16 @@ void KDirSharePlugin::slotPasswordEdited(const QString &value)
|
|||
emit changed();
|
||||
}
|
||||
|
||||
void KDirSharePlugin::updateServerLabel()
|
||||
{
|
||||
QDBusReply<QString> kdirsharereply = m_kdirshareiface.call("getAddress", m_url);
|
||||
if (!kdirsharereply.isValid()) {
|
||||
kWarning() << "Invalid kdirshare module reply for getAddress()";
|
||||
m_ui.serverlabel->setText(QString());
|
||||
} else {
|
||||
const QString kdirshareaddress = kdirsharereply.value();
|
||||
m_ui.serverlabel->setText(i18n("<html>The directory can be accessed at <a href=\"%1\">%1</a>.</html>", kdirshareaddress));
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_kdirshareplugin.cpp"
|
||||
|
|
|
@ -43,6 +43,8 @@ private Q_SLOTS:
|
|||
void slotPasswordEdited(const QString &value);
|
||||
|
||||
private:
|
||||
void updateServerLabel();
|
||||
|
||||
Ui_KDirShareUI m_ui;
|
||||
QDBusInterface m_kdirshareiface;
|
||||
QString m_url;
|
||||
|
|
|
@ -77,13 +77,13 @@
|
|||
<string>Authentication</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="authbox">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If restricted access to the share is desired this option may be turned on to require clients authentication with the specified user and password.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<property name="text">
|
||||
<string>Require authentication</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -100,6 +100,16 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="useredit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="passwordedit">
|
||||
<property name="echoMode">
|
||||
|
@ -107,16 +117,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="authbox">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If restricted access to the share is desired this option may be turned on to require clients authentication with the specified user and password.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Require authentication</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -133,6 +133,19 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="serverlabel">
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
|
@ -154,6 +154,16 @@ QString KDirShareModule::getPassword(const QString &dirpath) const
|
|||
return QString();
|
||||
}
|
||||
|
||||
QString KDirShareModule::getAddress(const QString &dirpath) const
|
||||
{
|
||||
foreach (const KDirShareImpl *kdirshareimpl, m_dirshares) {
|
||||
if (kdirshareimpl->directory() == dirpath) {
|
||||
return kdirshareimpl->address();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void KDirShareModule::slotDelayedRestore()
|
||||
{
|
||||
bool requiresauth = false;
|
||||
|
|
|
@ -48,6 +48,7 @@ public Q_SLOTS:
|
|||
Q_SCRIPTABLE quint16 getPortMax(const QString &dirpath) const;
|
||||
Q_SCRIPTABLE QString getUser(const QString &dirpath) const;
|
||||
Q_SCRIPTABLE QString getPassword(const QString &dirpath) const;
|
||||
Q_SCRIPTABLE QString getAddress(const QString &dirpath) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotDelayedRestore();
|
||||
|
|
|
@ -281,6 +281,14 @@ QString KDirShareImpl::password() const
|
|||
return m_password;
|
||||
}
|
||||
|
||||
QString KDirShareImpl::address() const
|
||||
{
|
||||
if (!m_kdirserver) {
|
||||
return QString();
|
||||
}
|
||||
return m_kdirserver->address();
|
||||
}
|
||||
|
||||
void KDirShareImpl::run()
|
||||
{
|
||||
m_kdirserver = new KDirServer();
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
quint16 portMax() const;
|
||||
QString user() const;
|
||||
QString password() const;
|
||||
QString address() const;
|
||||
|
||||
protected:
|
||||
void run() final;
|
||||
|
|
Loading…
Add table
Reference in a new issue