Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

networkmonitor: reformat (tabs to spaces)

  • Loading branch information...
commit 4d26de6eed39812e5b6486d863957644e0105898 1 parent bcf7d1b
@amoskvin amoskvin authored
View
171 razorqt-panel/plugin-networkmonitor/razornetworkmonitor.cpp
@@ -39,20 +39,20 @@ extern "C" {
EXPORT_RAZOR_PANEL_PLUGIN_CPP(RazorNetworkMonitor)
RazorNetworkMonitor::RazorNetworkMonitor(const RazorPanelPluginStartInfo* startInfo, QWidget* parent):
- RazorPanelPlugin(startInfo, parent)
+ RazorPanelPlugin(startInfo, parent)
{
- setObjectName("NetworkMonitor");
- addWidget(&m_stuff);
+ setObjectName("NetworkMonitor");
+ addWidget(&m_stuff);
- /* Initialise statgrab */
- sg_init();
+ /* Initialise statgrab */
+ sg_init();
- m_iconList << "modem" << "monitor"
- << "network" << "wireless";
+ m_iconList << "modem" << "monitor"
+ << "network" << "wireless";
- startTimer(800);
+ startTimer(800);
- settingsChanged();
+ settingsChanged();
}
RazorNetworkMonitor::~RazorNetworkMonitor()
@@ -61,107 +61,112 @@ RazorNetworkMonitor::~RazorNetworkMonitor()
void RazorNetworkMonitor::resizeEvent(QResizeEvent *)
{
- m_stuff.setMinimumWidth(m_pic.width()+2);
- m_stuff.setMinimumHeight(m_pic.height()+2);
+ m_stuff.setMinimumWidth(m_pic.width() + 2);
+ m_stuff.setMinimumHeight(m_pic.height() + 2);
- update();
+ update();
}
void RazorNetworkMonitor::timerEvent(QTimerEvent *event)
{
- bool matched = false;
-
- int num_network_stats;
-
- sg_network_io_stats *network_stats = sg_get_network_io_stats_diff(&num_network_stats);
-
- for(int x = 0; x < num_network_stats; x++)
- {
- if ( m_interface == QString::fromLocal8Bit(network_stats->interface_name) )
- {
- if ( network_stats->rx != 0 && network_stats->tx != 0 )
- {
- m_pic.load( iconName("transmit-receive") );
- } else if ( network_stats->rx != 0 && network_stats->tx == 0 )
- {
- m_pic.load( iconName("receive") );
- } else if ( network_stats->rx == 0 && network_stats->tx != 0 )
- {
- m_pic.load( iconName("transmit") );
- } else
- {
- m_pic.load( iconName("idle") );
- }
-
- matched = true;
-
- break;
- }
-
- network_stats++;
- }
-
- if( !matched)
- m_pic.load( iconName("error") );
-
- update();
+ bool matched = false;
+
+ int num_network_stats;
+
+ sg_network_io_stats *network_stats = sg_get_network_io_stats_diff(&num_network_stats);
+
+ for (int x = 0; x < num_network_stats; x++)
+ {
+ if (m_interface == QString::fromLocal8Bit(network_stats->interface_name))
+ {
+ if (network_stats->rx != 0 && network_stats->tx != 0)
+ {
+ m_pic.load(iconName("transmit-receive"));
+ }
+ else if (network_stats->rx != 0 && network_stats->tx == 0)
+ {
+ m_pic.load(iconName("receive"));
+ }
+ else if (network_stats->rx == 0 && network_stats->tx != 0)
+ {
+ m_pic.load(iconName("transmit"));
+ }
+ else
+ {
+ m_pic.load(iconName("idle"));
+ }
+
+ matched = true;
+
+ break;
+ }
+
+ network_stats++;
+ }
+
+ if (!matched)
+ {
+ m_pic.load(iconName("error"));
+ }
+
+ update();
}
-void RazorNetworkMonitor::paintEvent ( QPaintEvent * )
+void RazorNetworkMonitor::paintEvent(QPaintEvent *)
{
- QPainter p(this);
+ QPainter p(this);
- QRectF r = rect();
+ QRectF r = rect();
- int leftOffset = (r.width() - m_pic.width() + 2) / 2;
- int topOffset = (r.height() - m_pic.height() + 2) / 2;
+ int leftOffset = (r.width() - m_pic.width() + 2) / 2;
+ int topOffset = (r.height() - m_pic.height() + 2) / 2;
- p.drawPixmap(leftOffset, topOffset, m_pic);
+ p.drawPixmap(leftOffset, topOffset, m_pic);
}
bool RazorNetworkMonitor::event(QEvent *event)
{
- if(event->type() == QEvent::ToolTip)
- {
- int num_network_stats;
- sg_network_io_stats *network_stats = sg_get_network_io_stats(&num_network_stats);
- for(int x = 0; x < num_network_stats; x++)
- {
- if ( m_interface == QString::fromLocal8Bit(network_stats->interface_name) )
- {
- setToolTip(tr("Network interface <b>%1</b>").arg(m_interface) + "<br>"
- + tr("Transmitted %1").arg(convertUnits(network_stats->tx)) + "<br>"
- + tr("Received %1").arg(convertUnits(network_stats->rx))
- );
- }
- network_stats++;
- }
- }
- return RazorPanelPlugin::event(event);
+ if (event->type() == QEvent::ToolTip)
+ {
+ int num_network_stats;
+ sg_network_io_stats *network_stats = sg_get_network_io_stats(&num_network_stats);
+ for (int x = 0; x < num_network_stats; x++)
+ {
+ if (m_interface == QString::fromLocal8Bit(network_stats->interface_name))
+ {
+ setToolTip(tr("Network interface <b>%1</b>").arg(m_interface) + "<br>"
+ + tr("Transmitted %1").arg(convertUnits(network_stats->tx)) + "<br>"
+ + tr("Received %1").arg(convertUnits(network_stats->rx))
+ );
+ }
+ network_stats++;
+ }
+ }
+ return RazorPanelPlugin::event(event);
}
void RazorNetworkMonitor::showConfigureDialog()
{
- RazorNetworkMonitorConfiguration *confWindow =
- this->findChild<RazorNetworkMonitorConfiguration*>("RazorNetworkMonitorConfigurationWindow");
+ RazorNetworkMonitorConfiguration *confWindow =
+ this->findChild<RazorNetworkMonitorConfiguration*>("RazorNetworkMonitorConfigurationWindow");
- if (!confWindow)
- {
- confWindow = new RazorNetworkMonitorConfiguration(settings(), this);
- }
+ if (!confWindow)
+ {
+ confWindow = new RazorNetworkMonitorConfiguration(settings(), this);
+ }
- confWindow->show();
- confWindow->raise();
- confWindow->activateWindow();
+ confWindow->show();
+ confWindow->raise();
+ confWindow->activateWindow();
}
void RazorNetworkMonitor::settingsChanged()
{
- m_iconIndex = settings().value("icon", 1).toInt();
- m_interface = settings().value("interface", "eth0").toString();
+ m_iconIndex = settings().value("icon", 1).toInt();
+ m_interface = settings().value("interface", "eth0").toString();
- m_pic.load( iconName("error") );
+ m_pic.load(iconName("error"));
}
QString RazorNetworkMonitor::convertUnits(double num)
View
40 razorqt-panel/plugin-networkmonitor/razornetworkmonitor.h
@@ -35,39 +35,39 @@
*/
class RazorNetworkMonitor: public RazorPanelPlugin
{
- Q_OBJECT
+ Q_OBJECT
public:
- RazorNetworkMonitor(const RazorPanelPluginStartInfo* startInfo, QWidget* parent = 0);
- ~RazorNetworkMonitor();
+ RazorNetworkMonitor(const RazorPanelPluginStartInfo* startInfo, QWidget* parent = 0);
+ ~RazorNetworkMonitor();
- virtual RazorPanelPlugin::Flags flags() const { return PreferRightAlignment | HaveConfigDialog; }
+ virtual RazorPanelPlugin::Flags flags() const { return PreferRightAlignment | HaveConfigDialog; }
protected:
- void virtual timerEvent(QTimerEvent *event);
- void virtual paintEvent ( QPaintEvent * event );
- void virtual resizeEvent(QResizeEvent *);
- bool virtual event(QEvent *event);
+ void virtual timerEvent(QTimerEvent *event);
+ void virtual paintEvent(QPaintEvent * event);
+ void virtual resizeEvent(QResizeEvent *);
+ bool virtual event(QEvent *event);
protected slots:
- virtual void showConfigureDialog();
- virtual void settingsChanged();
+ virtual void showConfigureDialog();
+ virtual void settingsChanged();
private:
static QString convertUnits(double num);
- QString iconName(const QString& state) const
- {
- return QString(":/images/knemo-%1-%2.png")
- .arg(m_iconList[m_iconIndex], state );
- }
+ QString iconName(const QString& state) const
+ {
+ return QString(":/images/knemo-%1-%2.png")
+ .arg(m_iconList[m_iconIndex], state);
+ }
- QWidget m_stuff;
+ QWidget m_stuff;
- QStringList m_iconList;
+ QStringList m_iconList;
- int m_iconIndex;
+ int m_iconIndex;
- QString m_interface;
- QPixmap m_pic;
+ QString m_interface;
+ QPixmap m_pic;
};
View
48 razorqt-panel/plugin-networkmonitor/razornetworkmonitorconfiguration.cpp
@@ -30,46 +30,46 @@
#include "ui_razornetworkmonitorconfiguration.h"
RazorNetworkMonitorConfiguration::RazorNetworkMonitorConfiguration(QSettings &settings, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::RazorNetworkMonitorConfiguration),
- mSettings(settings),
- mOldSettings(settings)
+ QDialog(parent),
+ ui(new Ui::RazorNetworkMonitorConfiguration),
+ mSettings(settings),
+ mOldSettings(settings)
{
- setAttribute(Qt::WA_DeleteOnClose);
- setObjectName("NetworkMonitorConfigurationWindow");
- ui->setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose);
+ setObjectName("NetworkMonitorConfigurationWindow");
+ ui->setupUi(this);
- connect(ui->buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(dialogButtonsAction(QAbstractButton*)));
+ connect(ui->buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(dialogButtonsAction(QAbstractButton*)));
- loadSettings();
+ loadSettings();
}
RazorNetworkMonitorConfiguration::~RazorNetworkMonitorConfiguration()
{
- delete ui;
+ delete ui;
}
void RazorNetworkMonitorConfiguration::loadSettings()
{
- ui->iconCB->setCurrentIndex( mSettings.value("icon", 1).toInt() );
+ ui->iconCB->setCurrentIndex(mSettings.value("icon", 1).toInt());
- // TODO: use iface list from libstatgrab with editable combobox
- ui->interfaceLE->setText(mSettings.value("interface", "eth0").toString());
+ // TODO: use iface list from libstatgrab with editable combobox
+ ui->interfaceLE->setText(mSettings.value("interface", "eth0").toString());
}
void RazorNetworkMonitorConfiguration::dialogButtonsAction(QAbstractButton *btn)
{
- if (ui->buttons->buttonRole(btn) == QDialogButtonBox::ResetRole)
- {
- mOldSettings.loadToSettings();
- loadSettings();
- }
- else
- {
- mSettings.setValue("icon", ui->iconCB->currentIndex());
- mSettings.setValue("interface", ui->interfaceLE->text());
+ if (ui->buttons->buttonRole(btn) == QDialogButtonBox::ResetRole)
+ {
+ mOldSettings.loadToSettings();
+ loadSettings();
+ }
+ else
+ {
+ mSettings.setValue("icon", ui->iconCB->currentIndex());
+ mSettings.setValue("interface", ui->interfaceLE->text());
- close();
- }
+ close();
+ }
}
View
27 razorqt-panel/plugin-networkmonitor/razornetworkmonitorconfiguration.h
@@ -36,29 +36,30 @@
class QSettings;
class QAbstractButton;
-namespace Ui {
- class RazorNetworkMonitorConfiguration;
+namespace Ui
+{
+class RazorNetworkMonitorConfiguration;
}
class RazorNetworkMonitorConfiguration : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit RazorNetworkMonitorConfiguration(QSettings &settings, QWidget *parent = 0);
- ~RazorNetworkMonitorConfiguration();
+ explicit RazorNetworkMonitorConfiguration(QSettings &settings, QWidget *parent = 0);
+ ~RazorNetworkMonitorConfiguration();
private:
- Ui::RazorNetworkMonitorConfiguration *ui;
- QSettings &mSettings;
- RazorSettingsCache mOldSettings;
+ Ui::RazorNetworkMonitorConfiguration *ui;
+ QSettings &mSettings;
+ RazorSettingsCache mOldSettings;
private slots:
- /*
- Saves settings in conf file.
- */
- void loadSettings();
- void dialogButtonsAction(QAbstractButton *btn);
+ /*
+ Saves settings in conf file.
+ */
+ void loadSettings();
+ void dialogButtonsAction(QAbstractButton *btn);
};
#endif // RAZORNETWORKMONITORCONFIGURATION_H
Please sign in to comment.
Something went wrong with that request. Please try again.