[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/serverhotlink
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2008-10-02 19:38:54
Message-ID: 1222976334.571188.15931.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 867097 by aseigo:
various init and config usage fixes
M +7 -7 configuration.cpp
M +2 -2 configuration.h
M +28 -17 serverapplet.cpp
M +0 -1 serverapplet.h
--- trunk/playground/base/plasma/applets/serverhotlink/configuration.cpp #867096:867097
@@ -26,16 +26,16 @@
#include <KLocale>
-Configuration::Configuration(KConfigGroup *con, QList<struct service> *services){
+Configuration::Configuration(const KConfigGroup &con, QList<struct service> *services){
m_config = con;
base_services = services;
QGridLayout *layout = new QGridLayout();
//TODO: find out more about i18n and kde, and adapt the interace
QLabel *nameLabel = new QLabel("Server name");
- name = new QLineEdit(m_config->readEntry("name"));
+ name = new QLineEdit(m_config.readEntry("name"));
QLabel *addressLabel = new QLabel("Host address");
- hostAddress = new QLineEdit(m_config->readEntry("address"));
+ hostAddress = new QLineEdit(m_config.readEntry("address"));
QPushButton *ok = new QPushButton(i18n("0k"));
connect(ok, SIGNAL(clicked()), this, SLOT(ok()));
@@ -48,7 +48,7 @@
m_service_choices = new QButtonGroup();
m_service_choices->setExclusive(false);
- QStringList pre_selected = m_config->readEntry("services", QStringList());
+ QStringList pre_selected = m_config.readEntry("services", QStringList());
QLabel *kioLabel = new QLabel("KIO services");
int place = 0;
@@ -116,8 +116,8 @@
}
void Configuration::ok(){
- m_config->writeEntry("name",name->text());
- m_config->writeEntry("address",hostAddress->text());
+ m_config.writeEntry("name",name->text());
+ m_config.writeEntry("address",hostAddress->text());
QStringList services_selected;
@@ -126,7 +126,7 @@
services_selected << base_services->at(i).protocol;
}
- m_config->writeEntry("services",services_selected);
+ m_config.writeEntry("services",services_selected);
accept();
}
--- trunk/playground/base/plasma/applets/serverhotlink/configuration.h #867096:867097
@@ -46,14 +46,14 @@
Q_OBJECT
public:
// Basic Create/Destroy
- Configuration(KConfigGroup *con, QList<struct service> *services);
+ Configuration(const KConfigGroup &con, QList<struct service> *services);
~Configuration();
public slots:
void ok();
void cancel();
private:
- KConfigGroup *m_config;
+ KConfigGroup m_config;
QLineEdit *name;
QLineEdit *hostAddress;
--- trunk/playground/base/plasma/applets/serverhotlink/serverapplet.cpp #867096:867097
@@ -46,8 +46,6 @@
ServerApplet::ServerApplet(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args)
{
- m_config = config();
-
m_base_services = new QList<struct service>();
struct service fish = {"Fish", "fish", "folder-remote", SERVICE};
struct service ftp = {"Ftp", "ftp", "face-sad", SERVICE};
@@ -65,16 +63,13 @@
connect(m_services, SIGNAL(triggered( QAction *)), this, SLOT(openService(QAction *)));
m_icon = new KIcon("network-server");
- m_name = "NoName";//m_config.readEntry("name", "");
- m_address = m_config.readEntry("address", "");
+ m_name = i18n("No Server");
setHasConfigurationInterface(true);
setAspectRatioMode(Plasma::ConstrainedSquare);
setBackgroundHints(NoBackground);
//layout code
-
-
resize(200,200);
}
@@ -87,14 +82,20 @@
void ServerApplet::init()
{
+ KConfigGroup config = this->config();
+ m_name = config.readEntry("name", m_name);
+ m_address = config.readEntry("address", QString());
+
QGraphicsGridLayout *layout = new QGraphicsGridLayout;
Plasma::Icon *g_icon = new Plasma::Icon(*m_icon, "", this);
+ //FIXME: use Plasma::Label
m_name_label = new QLabel(m_name);
m_name_label->setAlignment(Qt::AlignHCenter);
QGraphicsProxyWidget *g_name = new QGraphicsProxyWidget;
g_name->setWidget(m_name_label);
+ //FIXME: this should just be a layout used to put Plasma::PushButtons in
m_actions = new QWidget();
layout_actions = new QVBoxLayout();
m_actions->setLayout(layout_actions);
@@ -111,29 +112,39 @@
setLayout(layout);
constructServices();
+
+ if (m_address.isEmpty()) {
+ setConfigurationRequired(true);
+ }
}
void ServerApplet::openService(QAction * action){
if(action->data().toString().compare("--ssh--") == 0){
- QString command = "konsole -e ssh "+m_config.readEntry("address","");
+ QString command = "konsole -e ssh " + m_address;
qDebug() << command;
KRun::runCommand(command,0);
- }else{
- //TODO:Memleak? read doc
- KRun *run = new KRun(action->data().toString()+"://" + m_config.readEntry("address",""), 0);
+ } else {
+ new KRun(action->data().toString()+"://" + m_address, 0);
}
}
-
-void ServerApplet::showConfigurationInterface(){
- Configuration conf(&m_config,m_base_services);
-
+
+//FIXME: port to createConigurationInterface
+void ServerApplet::showConfigurationInterface()
+{
+ KConfigGroup config = this->config();
+ Configuration conf(config, m_base_services);
+
conf.exec();
- m_name_label->setText(m_config.readEntry("name"));
+ m_name = config.readEntry("name", i18n("No Server"));
+ m_address = config.readEntry("address", QString());
+ setConfigurationRequired(m_address.isEmpty());
constructServices();
+ m_name_label->setText(m_name);
}
-void ServerApplet::constructServices(){
+void ServerApplet::constructServices()
+{
QList<QAction *> actions = m_services->actions();
for(int i = 0; i < actions.size(); i++){
m_services->removeAction(actions.at(i));
@@ -148,7 +159,7 @@
layout_actions = new QVBoxLayout();
m_actions->setLayout(layout_actions);
- QStringList list = m_config.readEntry("services", QStringList());
+ QStringList list = config().readEntry("services", QStringList());
for(int i = 0; i < list.size() ; i++){
//TODO: find a way to get pretty icons
--- trunk/playground/base/plasma/applets/serverhotlink/serverapplet.h #867096:867097
@@ -55,7 +55,6 @@
QString m_name;
QString m_address;
QActionGroup *m_services;
- KConfigGroup m_config;
QList<struct service> *m_base_services;
KIcon* m_icon;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic