Removed dbg package in favor of dbgsym. Removed unused files and licenses from copyright. Installed manpage.ubuntu/disco debian/1.10.16+20151210-1
parent
8166a027e7
commit
3e328b47c6
@ -0,0 +1 @@
|
||||
qps.1
|
Before Width: | Height: | Size: 2.8 KiB |
@ -0,0 +1,94 @@
|
||||
// checkboxdelegate.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "checkboxdelegate.h"
|
||||
|
||||
#include <QSpinBox>
|
||||
checkBoxDelegate::checkBoxDelegate(QObject *parent) : QItemDelegate(parent) {}
|
||||
//! [0]
|
||||
|
||||
//! [1]
|
||||
QWidget *checkBoxDelegate::createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("createEditor\n");
|
||||
// return 0;
|
||||
if (index.column() == 1)
|
||||
{
|
||||
QSpinBox *editor = new QSpinBox(parent);
|
||||
editor->setMinimum(0);
|
||||
editor->setMaximum(100);
|
||||
return editor;
|
||||
}
|
||||
return QItemDelegate::createEditor(parent, option, index);
|
||||
return 0;
|
||||
}
|
||||
//! [1]
|
||||
|
||||
//! [2]
|
||||
void checkBoxDelegate::setEditorData(QWidget *editor,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("setEditorData\n");
|
||||
return;
|
||||
// if(index
|
||||
if (index.column() == 1)
|
||||
{
|
||||
int value = index.model()->data(index, Qt::EditRole).toInt();
|
||||
// int value=0;
|
||||
QSpinBox *spinBox = static_cast<QSpinBox *>(editor);
|
||||
spinBox->setValue(value);
|
||||
}
|
||||
}
|
||||
//! [2]
|
||||
|
||||
//! [3]
|
||||
void checkBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("setModelData\n");
|
||||
return;
|
||||
if (index.column() == 1)
|
||||
{
|
||||
QSpinBox *spinBox = static_cast<QSpinBox *>(editor);
|
||||
spinBox->interpretText();
|
||||
int value = spinBox->value();
|
||||
model->setData(index, value, Qt::EditRole);
|
||||
}
|
||||
}
|
||||
//! [3]
|
||||
|
||||
//! [4]
|
||||
void checkBoxDelegate::updateEditorGeometry(QWidget *editor,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("updateEditorGeometry\n");
|
||||
// if(index.column()==1)
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
//! [4]
|
||||
|
||||
void checkBoxDelegate::paint(QPainter *painter,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
printf("paint\n");
|
||||
if (index.column() == 1)
|
||||
{
|
||||
QVariant value = 0; // index.model()->data(index, Qt::UserRole);
|
||||
/* if (!isSupportedType(value.type())) {
|
||||
QStyleOptionViewItem myOption = option;
|
||||
myOption.state &= ~QStyle::State_Enabled;
|
||||
QItemDelegate::paint(painter, myOption, index);
|
||||
return;
|
||||
} */
|
||||
}
|
||||
QItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
// QSize QAbstractItemDelegate::sizeHint ( const QStyleOptionViewItem & option,
|
||||
// const QModelIndex & index ) const [pure virtual]
|
||||
|
@ -0,0 +1,30 @@
|
||||
// checkboxdelegate.h
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
|
||||
#ifndef CHECKBOXDELEGATE_H
|
||||
#define CHECKBOXDELEGATE_H
|
||||
|
||||
#include <QItemDelegate>
|
||||
class checkBoxDelegate : public QItemDelegate
|
||||
// class checkBoxDelegate : public QAbstractItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
checkBoxDelegate(QObject *parent = 0);
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const;
|
||||
void updateEditorGeometry(QWidget *editor,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
#endif // CHECKBOXDELEGATE_H
|
@ -0,0 +1,257 @@
|
||||
// commanddialog.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "commanddialog.h"
|
||||
|
||||
#include "qps.h"
|
||||
#include "command.h"
|
||||
#include "commandutils.h"
|
||||
#include "commandmodel.h"
|
||||
|
||||
#include <QListView>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QModelIndex>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFrame>
|
||||
|
||||
extern QList<Command *> commands;
|
||||
|
||||
CommandDialog::CommandDialog()
|
||||
{
|
||||
setWindowTitle("Edit Commands 0.1 alpha");
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout(this); // TOP
|
||||
CommandModel *cmdModel = new CommandModel(this);
|
||||
// item list
|
||||
listview = new QListView(this);
|
||||
listview->setModel(cmdModel);
|
||||
listview->setFixedWidth(fontMetrics().width("0") * 16);
|
||||
hbox->addWidget(listview);
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout; // TOP-> RIGHT
|
||||
hbox->addLayout(vbox);
|
||||
|
||||
QHBoxLayout *h1 = new QHBoxLayout;
|
||||
vbox->addLayout(h1);
|
||||
QLabel *l1 = new QLabel("Name:", this);
|
||||
h1->addWidget(l1);
|
||||
name = new QLineEdit(this);
|
||||
name->setMinimumWidth(170);
|
||||
name->setText("");
|
||||
h1->addWidget(name);
|
||||
|
||||
QHBoxLayout *hbox2 = new QHBoxLayout;
|
||||
vbox->addLayout(hbox2);
|
||||
// qcheck1 = new QCheckBox (this);
|
||||
// qcheck1->setText("Toolbar");
|
||||
// qcheck1->setEnabled(false);
|
||||
// hbox2->addWidget(qcheck1);
|
||||
if (0)
|
||||
{
|
||||
qcheck2 = new QCheckBox(this);
|
||||
qcheck2->setText("Popup");
|
||||
qcheck2->setEnabled(false);
|
||||
hbox2->addWidget(qcheck2);
|
||||
}
|
||||
|
||||
QLabel *l2 = new QLabel("Command Line:", this);
|
||||
l2->setFixedHeight(l2->sizeHint().height());
|
||||
l2->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
vbox->addWidget(l2);
|
||||
|
||||
cmdline = new QLineEdit(this);
|
||||
cmdline->setFixedHeight(cmdline->sizeHint().height());
|
||||
cmdline->setMinimumWidth(250);
|
||||
cmdline->setText("");
|
||||
vbox->addWidget(cmdline);
|
||||
|
||||
QLabel *l3 = new QLabel("Substitutions:\n"
|
||||
"%p\tPID\n"
|
||||
"%c\tCOMMAND\n%C\tCMDLINE\n%u\tUSER\n"
|
||||
"%%\t%\n"
|
||||
"\n",
|
||||
this);
|
||||
|
||||
l3->setFrameStyle(QFrame::Panel);
|
||||
l3->setFrameShadow(QFrame::Sunken);
|
||||
l3->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); // | Qt::ExpandTabs);
|
||||
vbox->addWidget(l3);
|
||||
|
||||
QHBoxLayout *hl = new QHBoxLayout;
|
||||
vbox->addLayout(hl);
|
||||
new0 = new QPushButton("New...", this);
|
||||
hl->addWidget(new0);
|
||||
add = new QPushButton("Add...", this);
|
||||
hl->addWidget(add);
|
||||
del = new QPushButton("Delete", this);
|
||||
hl->addWidget(del);
|
||||
button_ok = new QPushButton("Close", this);
|
||||
hl->addWidget(button_ok);
|
||||
|
||||
connect(listview, SIGNAL(clicked(const QModelIndex &)),
|
||||
SLOT(set_select(const QModelIndex &)));
|
||||
connect(new0, SIGNAL(clicked()), SLOT(new_cmd()));
|
||||
connect(add, SIGNAL(clicked()), SLOT(add_new()));
|
||||
connect(del, SIGNAL(clicked()), SLOT(del_current()));
|
||||
connect(button_ok, SIGNAL(clicked()), SLOT(close()));
|
||||
connect(name, SIGNAL(textChanged(const QString &)),
|
||||
SLOT(event_name_midified(const QString &)));
|
||||
connect(cmdline, SIGNAL(textChanged(const QString &)),
|
||||
SLOT(event_cmd_modified()));
|
||||
// connect(qcheck1, SIGNAL(toggled ( bool ) ),
|
||||
// SLOT(event_toolbar_checked(bool
|
||||
// )));
|
||||
|
||||
TBloon *bloon = new TBloon(this);
|
||||
/// for(int i = 0; i < commands.size(); i++)
|
||||
/// listview->insertItem(commands[i]->name);
|
||||
// listview->addItem(commands[i]->name);
|
||||
/// vbox->freeze();
|
||||
}
|
||||
|
||||
// DEL
|
||||
void CommandDialog::event_toolbar_checked(bool on)
|
||||
{
|
||||
// name->text();
|
||||
int idx = find_command(name->text());
|
||||
if (idx >= 0)
|
||||
commands[idx]->toolbar = on;
|
||||
|
||||
/// controlbar->update_bar();
|
||||
}
|
||||
|
||||
void CommandDialog::event_name_midified(const QString &new_name)
|
||||
{
|
||||
int idx;
|
||||
FUNC_START;
|
||||
// printf("debug:changed_description() start \n");
|
||||
idx = find_command(new_name);
|
||||
if (idx == -1)
|
||||
{
|
||||
add->setEnabled(1);
|
||||
}
|
||||
else
|
||||
add->setEnabled(0);
|
||||
|
||||
// printf("debug:changed_description() end \n");
|
||||
}
|
||||
|
||||
// if modified then call this function
|
||||
void CommandDialog::event_cmd_modified()
|
||||
{
|
||||
int idx;
|
||||
// if(name->text()=="") return;
|
||||
if (find_command(name->text()) < 0)
|
||||
return;
|
||||
|
||||
idx = find_command(name->text());
|
||||
|
||||
commands[idx]->name = name->text();
|
||||
commands[idx]->cmdline = cmdline->text();
|
||||
emit command_change();
|
||||
}
|
||||
|
||||
// set the description,cmdline from current selected QListBox item
|
||||
void CommandDialog::set_buttons(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
new_cmd();
|
||||
return;
|
||||
}
|
||||
/*
|
||||
//bool sel = (lb->currentRow() >= 0);
|
||||
Command *c ;
|
||||
if(sel)
|
||||
//c = commands[find_command(lb->currentText())];
|
||||
c = commands[find_command(lb->currentText())];
|
||||
else
|
||||
c = commands[find_command(lb->text(index))];
|
||||
name->setText(c->name);
|
||||
cmdline->setText(c->cmdline);
|
||||
del->setEnabled(sel);
|
||||
*/
|
||||
}
|
||||
|
||||
// called when clicked !
|
||||
void CommandDialog::set_select(const QModelIndex &index)
|
||||
{
|
||||
Command *c =
|
||||
static_cast<Command *>(index.internalPointer()); // never Null ?
|
||||
/*
|
||||
if (item==NULL) return; // important
|
||||
Command *c = commands[find_command(item->text())];
|
||||
*/
|
||||
name->setText(c->name);
|
||||
cmdline->setText(c->cmdline);
|
||||
// DEL qcheck1->setChecked(c->toolbar);
|
||||
// qcheck2->setChecked(c->popup);
|
||||
|
||||
// bool sel = (listview->currentItem() >= 0);
|
||||
if (c->name == "Update")
|
||||
del->setEnabled(false);
|
||||
else
|
||||
del->setEnabled(true);
|
||||
}
|
||||
|
||||
void CommandDialog::reset()
|
||||
{
|
||||
listview->reset();
|
||||
name->setText("");
|
||||
cmdline->setText("");
|
||||
add->setText("Add...");
|
||||
add->setEnabled(0);
|
||||
button_ok->setEnabled(1);
|
||||
listview->clearSelection();
|
||||
}
|
||||
|
||||
void CommandDialog::new_cmd()
|
||||
{
|
||||
reset();
|
||||
add->setEnabled(1);
|
||||
name->setFocus();
|
||||
}
|
||||
|
||||
void CommandDialog::add_new()
|
||||
{
|
||||
if (name->text() == "")
|
||||
return;
|
||||
|
||||
// commands.add(new Command(name->text(),
|
||||
// cmdline->text(),qcheck1->isChecked
|
||||
// () ));
|
||||
commands.append(new Command(name->text(), cmdline->text(), false));
|
||||
check_commandAll(); // TEMP
|
||||
|
||||
listview->reset();
|
||||
add->setEnabled(0);
|
||||
del->setEnabled(0);
|
||||
button_ok->setEnabled(1);
|
||||
|
||||
emit command_change(); // notice to refresh Qps::make_command_menu()
|
||||
// control_bar->update_bar(); // ** important
|
||||
}
|
||||
|
||||
void CommandDialog::del_current()
|
||||
{
|
||||
int idx = find_command(name->text());
|
||||
if (idx >= 0)
|
||||
{
|
||||
// printf("del\n");
|
||||
commands.removeAt(idx);
|
||||
listview->reset(); // listview->reset();
|
||||
// control_bar->update_bar();
|
||||
emit command_change(); // notice to refresh menu_commands
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
// commanddialog.h
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
|
||||
#ifndef COMMANDDIALOG_H
|
||||
#define COMMANDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QListView;
|
||||
class QPushButton;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QModelIndex;
|
||||
|
||||
// class CommandDialog : public QWidget
|
||||
class CommandDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CommandDialog();
|
||||
|
||||
signals:
|
||||
void command_change();
|
||||
|
||||
protected slots:
|
||||
void new_cmd();
|
||||
void add_new();
|
||||
void del_current();
|
||||
void set_buttons(int);
|
||||
void reset();
|
||||
void set_select(const QModelIndex &);
|
||||
void event_name_midified(const QString &new_name);
|
||||
void event_cmd_modified();
|
||||
void event_toolbar_checked(bool);
|
||||
|
||||
private:
|
||||
QListView *listview;
|
||||
QPushButton *new0, *add, *del, *edit, *button_ok;
|
||||
QLineEdit *name, *cmdline;
|
||||
QCheckBox *qcheck1;
|
||||
QCheckBox *qcheck2;
|
||||
};
|
||||
|
||||
#endif // COMMANDDIALOG_H
|
@ -0,0 +1,47 @@
|
||||
// commandmodel.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "commandmodel.h"
|
||||
|
||||
#include "command.h"
|
||||
|
||||
extern QList<Command *> commands;
|
||||
|
||||
CommandModel::CommandModel(QObject *parent) {}
|
||||
CommandModel::~CommandModel() {}
|
||||
|
||||
QModelIndex CommandModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
if (row >= 0 and column >= 0 and row < commands.size() and column < 1)
|
||||
{
|
||||
Command *cmd = commands[row];
|
||||
return createIndex(row, column, cmd);
|
||||
}
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
QModelIndex CommandModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
int CommandModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return commands.size();
|
||||
}
|
||||
// int CommandModel::columnCount(const QModelIndex &parent) const{return 1;};
|
||||
QVariant CommandModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
Command *cmd = static_cast<Command *>(index.internalPointer());
|
||||
return cmd->name;
|
||||
}
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
void CommandModel::update() {} // TEMP
|
@ -0,0 +1,21 @@
|
||||
// commandmodel.h emacs, this is written in -*-c++-*-
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdegård, 1997-1999
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class CommandModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CommandModel(QObject *parent = 0);
|
||||
~CommandModel();
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||
QModelIndex parent(const QModelIndex &child) const;
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
int columnCount(const QModelIndex &parent) const { return 1; };
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
// Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
void update(); // TEMP
|
||||
};
|
@ -0,0 +1,76 @@
|
||||
// commandutils.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "commandutils.h"
|
||||
|
||||
#include <command.h>
|
||||
|
||||
extern QList<Command *> commands;
|
||||
|
||||
int find_command(QString s)
|
||||
{
|
||||
for (int i = 0; i < commands.size(); i++)
|
||||
if (s == commands[i]->name)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// DEL has "&" end of the string ?
|
||||
bool hasAmpersand(QString cmdline)
|
||||
{
|
||||
QString str;
|
||||
int len;
|
||||
str = cmdline.simplified();
|
||||
|
||||
if (str == "%update")
|
||||
return true; // internal command
|
||||
|
||||
len = str.length();
|
||||
if (str[len - 1] == '&')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void check_command(int idx) {}
|
||||
|
||||
//
|
||||
void check_commandAll()
|
||||
{
|
||||
int i, idx;
|
||||
|
||||
return;
|
||||
for (int i = 0; i < commands.size(); i++)
|
||||
{
|
||||
if (hasAmpersand(commands[i]->cmdline) == false)
|
||||
commands[i]->cmdline.append("&");
|
||||
}
|
||||
}
|
||||
|
||||
// after read ~/.qpsrc
|
||||
void add_default_command()
|
||||
{
|
||||
|
||||
int idx;
|
||||
|
||||
/*
|
||||
idx=find_command("Update");
|
||||
if (idx>=0)
|
||||
commands[idx]->cmdline="%update";
|
||||
else
|
||||
commands.add(new Command("Update","%update",true));
|
||||
*/
|
||||
|
||||
/*
|
||||
* PAUSED
|
||||
idx=find_command("Quit");
|
||||
if (idx>=0)
|
||||
commands[idx]->cmdline="killall qps";
|
||||
else commands.add(new Command("Quit","killall qps",false));
|
||||
*/
|
||||
|
||||
// check_commandAll(); DEL?
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
// commandutils.h
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#ifndef COMMANDUTILS_H
|
||||
#define COMMANDUTILS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
int find_command(QString s);
|
||||
bool hasAmpersand(QString cmdline);
|
||||
void check_command(int idx);
|
||||
void check_commandAll();
|
||||
void add_default_command();
|
||||
|
||||
#endif // COMMANDUTILS_H
|
@ -0,0 +1,112 @@
|
||||
// execwindow.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "execwindow.h"
|
||||
|
||||
#include "watchcond.h"
|
||||
|
||||
QList<ExecWindow *> execlist;
|
||||
|
||||
// ExecWindow
|
||||
ExecWindow::ExecWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
// connect(okButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
// show();
|
||||
}
|
||||
|
||||
ExecWindow::~ExecWindow() {}
|
||||
|
||||
// eventcat_id;
|
||||
ExecWindow::ExecWindow(watchCond *wc, int pid, QString cmd)
|
||||
{
|
||||
setupUi(this);
|
||||
setWindowTitle("Qps Watchdog");
|
||||
|
||||
wcond = wc;
|
||||
|
||||
QString str;
|
||||
|
||||
if (wc->cond == WATCH_PROCESS_START)
|
||||
{
|
||||
textEdit->append(cmd + "(" + QString::number(pid) + ")" + " start");
|
||||
}
|
||||
if (wc->cond == WATCH_PROCESS_FINISH)
|
||||
textEdit->append(cmd + "(" + QString::number(pid) + ")" + " finished");
|
||||
|
||||
flag_started = false;
|
||||
|
||||
pr = new QProcess; // leak?
|
||||
if (!wc->command.isEmpty()) // conflict pid's command
|
||||
{
|
||||
pr->start(wc->command); // thread run, if null then segfault occurs. ?
|
||||
}
|
||||
|
||||
connect(okButton, SIGNAL(clicked()), this, SLOT(cmd_ok()));
|
||||
|
||||
connect(pr, SIGNAL(started()), this, SLOT(cmd_started()));
|
||||
connect(pr, SIGNAL(finished(int, QProcess::ExitStatus)), this,
|
||||
SLOT(cmd_finished(int, QProcess::ExitStatus)));
|
||||
connect(pr, SIGNAL(error(QProcess::ProcessError)), this,
|
||||
SLOT(cmd_error(QProcess::ProcessError)));
|
||||
|
||||
show();
|
||||
|
||||
execlist.append(this);
|
||||
}
|
||||
|
||||
ExecWindow::ExecWindow(QString str, QString exec_cmd, int pid, QString cmd)
|
||||
{
|
||||
setupUi(this);
|
||||
//
|
||||
}
|
||||
|
||||
// QProcess: Destroyed while process is still running.(Segmentation fault)
|
||||
void ExecWindow::cmd_ok()
|
||||
{
|
||||
if (pr->state() == QProcess::Running)
|
||||
{
|
||||
// pr->kill();
|
||||
pr->terminate();
|
||||
return;
|
||||
}
|
||||
close(); // Qt::WA_DeleteOnClose
|
||||
}
|
||||
|
||||
// slot : catch terminate signal.
|
||||
void ExecWindow::cmd_finished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
textEdit->append(wcond->command + " exit with code " +
|
||||
QString::number(exitStatus));
|
||||
okButton->setText("Close");
|
||||
delete pr;
|
||||
}
|
||||
|
||||
void ExecWindow::cmd_started()
|
||||
{
|
||||
textEdit->append(wcond->command + " [running]");
|
||||
okButton->setText("terminate command");
|
||||
flag_started = true;
|
||||
}
|
||||
|
||||
void ExecWindow::cmd_error(QProcess::ProcessError e)
|
||||
{
|
||||
// not found command
|
||||
// Error ? :
|
||||
if (e == QProcess::FailedToStart)
|
||||
// textEdit->append("Error : command not found [" +
|
||||
// command + "]" + "(code
|
||||
//" + QString::number(e) + ")" );
|
||||
textEdit->append("Error " + QString::number(e) + " : [" +
|
||||
wcond->command + "] Maybe command not found");
|
||||
delete pr;
|
||||
}
|
||||
|
||||
void ExecWindow::setText(QString str)
|
||||
{
|
||||
textEdit->append(str);
|
||||
// label->setText(str);
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
// execwindow.h
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#ifndef EXECWINDOW_H
|
||||
#define EXECWINDOW_H
|
||||
|
||||
#include <QProcess>
|
||||
#include <QString>
|
||||
|
||||
#include "ui_message.h"
|
||||
|
||||
class watchCond;
|
||||
|
||||
class ExecWindow : public QWidget, private Ui_ExecWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ExecWindow();
|
||||
ExecWindow(QString str, QString exec_cmd, int pid = 0, QString cmd = "");
|
||||
ExecWindow(watchCond *wc, int pid = 0, QString cmd = "");
|
||||
~ExecWindow();
|
||||
void setText(QString str);
|
||||
QProcess *pr;
|
||||
// QProcess proc;
|
||||
QString execmd;
|
||||
int flag_started;
|
||||
watchCond *wcond;
|
||||
protected slots:
|
||||
void cmd_started();
|
||||
void cmd_finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void cmd_error(QProcess::ProcessError error);
|
||||
void cmd_ok();
|
||||
};
|
||||
|
||||
#endif // EXECWINDOW_H
|
@ -0,0 +1,107 @@
|
||||
// listmodel.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "listmodel.h"
|
||||
|
||||
#include "watchcond.h"
|
||||
|
||||
extern QList<watchCond *> watchlist;
|
||||
|
||||
QModelIndex ListModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
// printf("index %d %d\n",row,column);
|
||||
if (row >= 0 and column >= 0 and row < watchlist.size())
|
||||
{
|
||||
if (column < 2)
|
||||
{
|
||||
watchCond *item = watchlist[row];
|
||||
return createIndex(row, column, item);
|
||||
}
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
void ListModel::update(int row)
|
||||
{
|
||||
emit dataChanged(index(row, 0), index(row, 1));
|
||||
}
|
||||
|
||||
void ListModel::update(const QModelIndex &idx) { emit dataChanged(idx, idx); }
|
||||
|
||||
// Pure Virtual
|
||||
QModelIndex ListModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
return QModelIndex(); // no parent!
|
||||
}
|
||||
int ListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return watchlist.size();
|
||||
}
|
||||
QVariant ListModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
// printf("headerData\n");
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
if (section == 0)
|
||||
return QString("Event Category");
|
||||
if (section == 1)
|
||||
return QString("Enable");
|
||||
}
|
||||
/*
|
||||
if (role == Qt::FontRole)
|
||||
{
|
||||
QFont f=QFont();
|
||||
f.setBold(false);
|
||||
return f;
|
||||
} */
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
// return QSize(18,18);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant ListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
// printf("data\n");
|
||||
watchCond *item = static_cast<watchCond *>(index.internalPointer());
|
||||
if (index.column() == 0)
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return QString(item->getstring());
|
||||
}
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
}
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (index.column() == 1)
|
||||
{
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (item->enable)
|
||||
return Qt::Checked;
|
||||
else
|
||||
return Qt::Unchecked;
|
||||
}
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignRight;
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
// return QSize(18,18);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
// listmodel.h
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#ifndef LISTMODEL_H
|
||||
#define LISTMODEL_H
|
||||
|
||||
#include <QStandardItemModel>
|
||||
// class ListModel : public QAbstractItemModel
|
||||
class ListModel : public QAbstractTableModel
|
||||
// class ListModel : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ListModel(QObject *parent = 0){};
|
||||
~ListModel(){};
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const; // pure
|
||||
QModelIndex parent(const QModelIndex &child) const; // pure virtual
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
int columnCount(const QModelIndex &parent) const { return 2; };
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation o, int role) const;
|
||||
// QMap<int, QVariant> itemData ( const QModelIndex & index ) const
|
||||
//;
|
||||
void update()
|
||||
{ // reset();
|
||||
}
|
||||
void update(const QModelIndex &idx);
|
||||
void update(int row);
|
||||
// Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
// void update(); //TEMP
|
||||
};
|
||||
|
||||
#endif // LISTMODEL_H
|
@ -0,0 +1,61 @@
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
// fasthyun@magicn.com 2005-2012
|
||||
// daehyun.yang@gmail.com 2015-
|
||||
|
||||
#include "qpsapp.h"
|
||||
|
||||
void QpsApp::saveState(QSessionManager &manager)
|
||||
{
|
||||
// printf("saveState()\n");
|
||||
// manager.setRestartHint(QSessionManager::RestartIfRunning);
|
||||
// manager.release();
|
||||
}
|
||||
|
||||
// this is called when X Logout
|
||||
// closeEvent() never called !!
|
||||
void QpsApp::commitData(QSessionManager &manager)
|
||||
{
|
||||
/*
|
||||
printf("commitData()\n");
|
||||
manager.setRestartHint(QSessionManager::RestartIfRunning);
|
||||
qps->flag_exit=true; // ready to Logout
|
||||
qps->save_settings() ;
|
||||
manager.release();
|
||||
sleep(2);
|
||||
return;
|
||||
if (manager.allowsInteraction()) {
|
||||
int ret = QMessageBox::warning(
|
||||
qps,
|
||||
tr("My Application"),
|
||||
tr("Save changes to document?"),
|
||||
QMessageBox::Save | QMessageBox::Discard |
|
||||
QMessageBox::Cancel);
|
||||
|
||||
switch (ret) {
|
||||
case QMessageBox::Save:
|
||||
manager.release();
|
||||
// if (!saveDocument()) manager.cancel();
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
default:
|
||||
manager.cancel();
|
||||
}
|
||||
} else {
|
||||
|
||||
manager.release();
|
||||
|
||||
// we did not get permission to interact, then
|
||||
// do something reasonable instead
|
||||
}
|
||||
*/
|
||||
/*
|
||||
//DEL sm.release();
|
||||
qDebug("Qps: Session saved\n");
|
||||
// sm.cancel();
|
||||
//sm.setRestartHint (QSessionManager::RestartIfRunning);
|
||||
QApplication::commitData(sm);
|
||||
*/
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
// fasthyun@magicn.com 2005-2012
|
||||
// daehyun.yang@gmail.com 2015-
|
||||
|
||||
#ifndef QPSAPP_H
|
||||
#define QPSAPP_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
// MOD!!!: For systray update.
|
||||
// this trick very suck, but I can't find a better solution.
|
||||
class QpsApp : public QApplication
|
||||
{
|
||||
public:
|
||||
QpsApp(int &argc, char **argv) : QApplication(argc, argv){};
|
||||
void commitData(QSessionManager &sm);
|
||||
void saveState(QSessionManager &manager);
|
||||
|
||||
/*
|
||||
virtual bool x11EventFilter ( XEvent *xev ){
|
||||
// catch X11 event for systray_update !! which event?
|
||||
///if(trayicon!=NULL) return
|
||||
trayicon->checkNewTrayEvent(xev);
|
||||
return false; // events to qt.
|
||||
}; */
|
||||
};
|
||||
|
||||
#endif // QPSAPP_H
|
@ -1,389 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at qt-sales@nokia.com.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qticonloader.h"
|
||||
#include <QtGui/QPixmapCache>
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QLibrary>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
|
||||
class QIconTheme
|
||||
{
|
||||
public:
|
||||
QIconTheme(QHash<int, QString> dirList, QStringList parents)
|
||||
: _dirList(dirList), _parents(parents), _valid(true)
|
||||
{
|
||||
}
|
||||
QIconTheme() : _valid(false) {}
|
||||
QHash<int, QString> dirList() { return _dirList; }
|
||||
QStringList parents() { return _parents; }
|
||||
bool isValid() { return _valid; }
|
||||
|
||||
private:
|
||||
QHash<int, QString> _dirList;
|
||||
QStringList _parents;
|
||||
bool _valid;
|
||||
};
|
||||
|
||||
class QtIconLoaderImplementation
|
||||
{
|
||||
public:
|
||||
QtIconLoaderImplementation();
|
||||
QPixmap findIcon(int size, const QString &name) const;
|
||||
|
||||
private:
|
||||
QIconTheme parseIndexFile(const QString &themeName) const;
|
||||
void lookupIconTheme() const;
|
||||
QPixmap findIconHelper(int size, const QString &themeName,
|
||||
const QString &iconName, QStringList &visited) const;
|
||||
mutable QString themeName;
|
||||
mutable QStringList iconDirs;
|
||||
mutable QHash<QString, QIconTheme> themeList;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(QtIconLoaderImplementation, iconLoaderInstance)
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
||||
Returns the standard icon for the given icon /a name
|
||||
as specified in the freedesktop icon spec
|
||||
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
|
||||
|
||||
/a fallback is an optional argument to specify the icon to be used if
|
||||
no icon is found on the platform. This is particularily useful for
|
||||
crossplatform code.
|
||||
|
||||
*/
|
||||
QIcon QtIconLoader::icon(const QString &name, const QIcon &fallback)
|
||||
{
|
||||
QIcon icon;
|
||||
#ifdef Q_WS_X11
|
||||
QString pngExtension(QLatin1String(".png"));
|
||||
QList<int> iconSizes;
|
||||
iconSizes << 16 << 24 << 32 << 48 << 64;
|
||||
Q_FOREACH (int size, iconSizes)
|
||||
{
|
||||
icon.addPixmap(
|
||||
iconLoaderInstance()->findIcon(size, name + pngExtension));
|
||||
// icon.addPixmap(iconLoaderInstance()->findIcon(size,
|
||||
// name));
|
||||
}
|
||||
#endif
|
||||
if (icon.isNull())
|
||||
icon = fallback;
|
||||
Q_UNUSED(name);
|
||||
return icon;
|
||||
}
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
|
||||
QtIconLoaderImplementation::QtIconLoaderImplementation() { lookupIconTheme(); }
|
||||
|
||||
extern "C" {
|
||||
struct GConfClient;
|
||||
struct GError;
|
||||
typedef void (*Ptr_g_type_init)();
|
||||
typedef GConfClient *(*Ptr_gconf_client_get_default)();
|
||||
typedef char *(*Ptr_gconf_client_get_string)(GConfClient *, const char *,
|
||||
GError **);
|
||||
typedef void (*Ptr_g_object_unref)(void *);
|
||||
typedef void (*Ptr_g_error_free)(GError *);
|
||||
typedef void (*Ptr_g_free)(void *);
|
||||
static Ptr_g_type_init p_g_type_init = 0;
|
||||
static Ptr_gconf_client_get_default p_gconf_client_get_default = 0;
|
||||
static Ptr_gconf_client_get_string p_gconf_client_get_string = 0;
|
||||
static Ptr_g_object_unref p_g_object_unref = 0;
|
||||
static Ptr_g_error_free p_g_error_free = 0;
|
||||
static Ptr_g_free p_g_free = 0;
|
||||
}
|
||||
|
||||
static int kdeVersion()
|
||||
{
|
||||
static int version = qgetenv("KDE_SESSION_VERSION").toInt();
|
||||
return version;
|
||||
}
|
||||
|
||||
static QString kdeHome()
|
||||
{
|
||||
static QString kdeHomePath;
|
||||
if (kdeHomePath.isEmpty())
|
||||
{
|
||||
kdeHomePath = QFile::decodeName(qgetenv("KDEHOME"));
|
||||
if (kdeHomePath.isEmpty())
|
||||
{
|
||||
int kdeSessionVersion = kdeVersion();
|
||||
QDir homeDir(QDir::homePath());
|
||||
QString kdeConfDir(QLatin1String("/.kde"));
|
||||
if (4 == kdeSessionVersion &&
|
||||
homeDir.exists(QLatin1String(".kde4")))
|
||||
kdeConfDir = QLatin1String("/.kde4");
|
||||
kdeHomePath = QDir::homePath() + kdeConfDir;
|
||||
}
|
||||
}
|
||||
return kdeHomePath;
|
||||
}
|
||||
|
||||
void QtIconLoaderImplementation::lookupIconTheme() const
|
||||
{
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
QString dataDirs = QFile::decodeName(getenv("XDG_DATA_DIRS"));
|
||||
if (dataDirs.isEmpty())
|
||||
dataDirs = QLatin1String("/usr/local/share/:/usr/share/");
|
||||
|
||||
dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));
|
||||
iconDirs = dataDirs.split(QLatin1Char(':'));
|
||||
|
||||
// If we are running GNOME we resolve and use GConf. In all other
|
||||
// cases we currently use the KDE icon theme
|
||||
|
||||
if (qgetenv("DESKTOP_SESSION") == "gnome" ||
|
||||
!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty())
|
||||
{
|
||||
|
||||
if (themeName.isEmpty())
|
||||
{
|
||||
// Resolve glib and gconf
|
||||
|
||||
p_g_type_init = (Ptr_g_type_init)QLibrary::resolve(
|
||||
QLatin1String("gobject-2.0"), 0, "g_type_init");
|
||||
p_gconf_client_get_default =
|
||||
(Ptr_gconf_client_get_default)QLibrary::resolve(
|
||||
QLatin1String("gconf-2"), 4, "gconf_client_get_default");
|
||||
p_gconf_client_get_string =
|
||||
(Ptr_gconf_client_get_string)QLibrary::resolve(
|
||||
QLatin1String("gconf-2"), 4, "gconf_client_get_string");
|
||||
p_g_object_unref = (Ptr_g_object_unref)QLibrary::resolve(
|
||||
QLatin1String("gobject-2.0"), 0, "g_object_unref");
|
||||
p_g_error_free = (Ptr_g_error_free)QLibrary::resolve(
|
||||
QLatin1String("glib-2.0"), 0, "g_error_free");
|
||||
p_g_free = (Ptr_g_free)QLibrary::resolve(QLatin1String("glib-2.0"),
|
||||
0, "g_free");
|
||||
|
||||
if (p_g_type_init && p_gconf_client_get_default &&
|
||||
p_gconf_client_get_string && p_g_object_unref &&
|
||||
p_g_error_free && p_g_free)
|
||||
{
|
||||
|
||||
p_g_type_init();
|
||||
GConfClient *client = p_gconf_client_get_default();
|
||||
GError *err = 0;
|
||||
|
||||
char *str = p_gconf_client_get_string(
|
||||
client, "/desktop/gnome/interface/icon_theme", &err);
|
||||
if (!err)
|
||||
{
|
||||
themeName = QString::fromUtf8(str);
|
||||
p_g_free(str);
|
||||
}
|
||||
|
||||
p_g_object_unref(client);
|
||||
if (err)
|
||||
p_g_error_free(err);
|
||||
}
|
||||
if (themeName.isEmpty())
|
||||
themeName = QLatin1String("gnome");
|
||||
}
|
||||
|
||||
if (!themeName.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
// KDE (and others)
|
||||
if (dataDirs.isEmpty())
|
||||
dataDirs = QLatin1String("/usr/local/share/:/usr/share/");
|
||||
|
||||
dataDirs += QLatin1Char(':') + kdeHome() + QLatin1String("/share");
|
||||
dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));
|
||||
QStringList kdeDirs =
|
||||
QFile::decodeName(getenv("KDEDIRS")).split(QLatin1Char(':'));
|
||||
Q_FOREACH (const QString dirName, kdeDirs)
|
||||
dataDirs.append(QLatin1Char(':') + dirName + QLatin1String("/share"));
|
||||
iconDirs = dataDirs.split(QLatin1Char(':'));
|
||||
|
||||
QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));
|
||||
QDir dir(fileInfo.canonicalFilePath());
|
||||
QString kdeDefault = kdeVersion() >= 4 ? QString::fromLatin1("oxygen")
|
||||
: QString::fromLatin1("crystalsvg");
|
||||
QString defaultTheme = fileInfo.exists() ? dir.dirName() : kdeDefault;
|
||||
QSettings settings(kdeHome() + QLatin1String("/share/config/kdeglobals"),
|
||||
QSettings::IniFormat);
|
||||
settings.beginGroup(QLatin1String("Icons"));
|
||||
themeName = settings.value(QLatin1String("Theme"), defaultTheme).toString();
|
||||
#endif
|
||||
}
|
||||
|
||||
QIconTheme
|
||||
QtIconLoaderImplementation::parseIndexFile(const QString &themeName) const
|
||||
{
|
||||
QIconTheme theme;
|
||||
QFile themeIndex;
|
||||
QStringList parents;
|
||||
QHash<int, QString> dirList;
|
||||
|
||||
for (int i = 0; i < iconDirs.size() && !themeIndex.exists(); ++i)
|
||||
{
|
||||
const QString &contentDir = QLatin1String(
|
||||
iconDirs[i].startsWith(QDir::homePath()) ? "/.icons/" : "/icons/");
|
||||
themeIndex.setFileName(iconDirs[i] + contentDir + themeName +
|
||||
QLatin1String("/index.theme"));
|
||||
}
|
||||
|
||||
if (themeIndex.exists())
|
||||
{
|
||||
QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
|
||||
Q_FOREACH (const QString &key, indexReader.allKeys())
|
||||
{
|
||||
if (key.endsWith("/Size"))
|
||||
{
|
||||
if (int size = indexReader.value(key).toInt())
|
||||
dirList.insertMulti(size, key.left(key.size() - 5));
|
||||
}
|
||||
}
|
||||
|
||||
// Parent themes provide fallbacks for missing icons
|
||||
parents = indexReader.value(QLatin1String("Icon Theme/Inherits"))
|
||||
.toStringList();
|
||||
}
|
||||
|
||||
if (kdeVersion() >= 3)
|
||||
{
|
||||
QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));
|
||||
QDir dir(fileInfo.canonicalFilePath());
|
||||
QString defaultKDETheme =
|
||||
dir.exists() ? dir.dirName()
|
||||
: kdeVersion() == 3 ? QString::fromLatin1("crystalsvg")
|
||||
: QString::fromLatin1("oxygen");
|
||||
if (!parents.contains(defaultKDETheme) && themeName != defaultKDETheme)
|
||||
parents.append(defaultKDETheme);
|
||||
}
|
||||
else if (parents.isEmpty() && themeName != QLatin1String("hicolor"))
|
||||
{
|
||||
parents.append(QLatin1String("hicolor"));
|
||||
}
|
||||
|
||||
theme = QIconTheme(dirList, parents);
|
||||
return theme;
|
||||
}
|
||||
|
||||
QPixmap QtIconLoaderImplementation::findIconHelper(int size,
|
||||
const QString &themeName,
|
||||
const QString &iconName,
|
||||
QStringList &visited) const
|
||||
{
|
||||
QPixmap pixmap;
|
||||
|
||||
if (!themeName.isEmpty())
|
||||
{
|
||||
visited << themeName;
|
||||
QIconTheme theme = themeList.value(themeName);
|
||||
|
||||
if (!theme.isValid())
|
||||
{
|
||||
theme = parseIndexFile(themeName);
|
||||
themeList.insert(themeName, theme);
|
||||
}
|
||||
|
||||
if (!theme.isValid())
|
||||
return QPixmap();
|
||||
|
||||
QList<QString> subDirs = theme.dirList().values(size);
|
||||
|
||||
for (int i = 0; i < iconDirs.size(); ++i)
|
||||
{
|
||||
for (int j = 0; j < subDirs.size(); ++j)
|
||||
{
|
||||
QString contentDir = (iconDirs[i].startsWith(QDir::homePath()))
|
||||
? QLatin1String("/.icons/")
|
||||
: QLatin1String("/icons/");
|
||||
QString fileName = iconDirs[i] + contentDir + themeName +
|
||||
QLatin1Char('/') + subDirs[j] +
|
||||
QLatin1Char('/') + iconName;
|
||||
QFile file(fileName);
|
||||
if (file.exists())
|
||||
pixmap.load(fileName);
|
||||
if (!pixmap.isNull())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pixmap.isNull())
|
||||
{
|
||||
QStringList parents = theme.parents();
|
||||
// search recursively through inherited themes
|
||||
for (int i = 0; pixmap.isNull() && i < parents.size(); ++i)
|
||||
{
|
||||
QString parentTheme = parents[i].trimmed();
|
||||
if (!visited.contains(parentTheme)) // guard
|
||||
// against
|
||||
// endless
|
||||
// recursion
|
||||
pixmap =
|
||||
findIconHelper(size, parentTheme, iconName, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmap QtIconLoaderImplementation::findIcon(int size,
|
||||
const QString &name) const
|
||||
{
|
||||
QPixmap pixmap;
|
||||
QString pixmapName = QLatin1String("$qt") + name + QString::number(size);
|
||||
if (QPixmapCache::find(pixmapName, pixmap))
|
||||
return pixmap;
|
||||
|
||||
if (!themeName.isEmpty())
|
||||
{
|
||||
QStringList visited;
|
||||
pixmap = findIconHelper(size, themeName, name, visited);
|
||||
}
|
||||
QPixmapCache::insert(pixmapName, pixmap);
|
||||
return pixmap;
|
||||
}
|
||||
#endif // Q_WS_X11
|
@ -1,55 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain
|
||||
** additional rights. These rights are described in the Nokia Qt LGPL
|
||||
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
||||
** package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at qt-sales@nokia.com.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTICONLOADER_H
|
||||
#define QTICONLOADER_H
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
// This is the QtIconLoader
|
||||
// Version 0.1
|
||||
//
|
||||
|
||||
class QtIconLoader
|
||||
{
|
||||
public:
|
||||
static QIcon icon(const QString &name, const QIcon &fallback = QIcon());
|
||||
};
|
||||
|
||||
#endif // QTICONLOADER_H
|
@ -0,0 +1,18 @@
|
||||
// tablefield.h emacs, this is written in -*-c++-*-
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdegård, 1997-1999
|
||||
|
||||
#ifndef TABLEFIELD_H
|
||||
#define TABLEFIELD_H
|
||||
|
||||
struct TableField
|
||||
{
|
||||
const char *name;
|
||||
int width;
|
||||
int gap;
|
||||
int align;
|
||||
const char *tooltip;
|
||||
};
|
||||
|
||||
#endif // TABLEFIELD_H
|
@ -0,0 +1,76 @@
|
||||
// watchcond.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "watchcond.h"
|
||||
|
||||
QString watchCond::getVal(QString &str, const char *key)
|
||||
{
|
||||
int n; // key.length();
|
||||
int idx = str.indexOf(key);
|
||||
if (idx < 0)
|
||||
return "cant' found";
|
||||
|
||||
idx = str.indexOf("[", idx);
|
||||
if (idx < 0)
|
||||
return "[ error";
|
||||
int idx_end = str.indexOf("]", idx);
|
||||
if (idx_end < 0)
|
||||
return "] error";
|
||||
n = idx_end - idx;
|
||||
return str.mid(idx + 1, n - 1);
|
||||
}
|
||||
QString watchCond::getstring()
|
||||
{
|
||||
QString string;
|
||||
string.clear();
|
||||
switch (cond)
|
||||
{
|
||||
case WATCH_PROCESS_FINISH:
|
||||
string.append("if process [" + procname + "] finish, ");
|
||||
// string=string.sprintf("if process [%s] finish",procname);
|
||||
break;
|
||||
case WATCH_PROCESS_START:
|
||||
string.append("if process [" + procname + "] start, ");
|
||||
break;
|
||||
case WATCH_SYS_CPU_OVER:
|
||||
string.append("if sys_cpu over [" + QString::number(cpu) + "], ");
|
||||
break;
|
||||
case WATCH_SYS_CPU_UNDER:
|
||||
string.append("if sys_cpu under [" + QString::number(cpu) + "], ");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
if (!command.isEmpty())
|
||||
string.append("exec [" + command + "] ");
|
||||
if (!message.isEmpty())
|
||||
string.append("showmsg [" + message + "] ");
|
||||
if (enable)
|
||||
string.append("enabled");
|
||||
else
|
||||
string.append("disabled");
|
||||
|
||||
return string;
|
||||
}
|
||||
void watchCond::putstring(QString str)
|
||||
{
|
||||
if (str.contains("if process"))
|
||||
{
|
||||
if (str.contains("start"))
|
||||
cond = WATCH_PROCESS_START;
|
||||
if (str.contains("finish"))
|
||||
cond = WATCH_PROCESS_FINISH;
|
||||
procname = getVal(str, "if process");
|
||||
}
|
||||
if (str.contains("exec"))
|
||||
command = getVal(str, "exec");
|
||||
if (str.contains("showmsg"))
|
||||
message = getVal(str, "showmsg");
|
||||
if (str.contains("enabled"))
|
||||
enable = true;
|
||||
else
|
||||
enable = false;
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
// watchcond.h
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#ifndef WATCHCOND_H
|
||||
#define WATCHCOND_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#define WATCH_PROCESS_START 0
|
||||
#define WATCH_PROCESS_FINISH 1
|
||||
#define WATCH_PROCESS_CPU_OVER 2
|
||||
#define WATCH_SYS_CPU_OVER 3
|
||||
#define WATCH_SYS_CPU_UNDER 4
|
||||
|
||||
|
||||
// if process [name] start, exec [command], showmsg [xxx]
|
||||
// if process [name] finish exec [command], showmsg [xxx]
|
||||
// if system cpu over [90%], exec [command], msg [xxx]
|
||||
// if system cpu under [10%], exec [command], msg [xxx]
|
||||
// if process [name] cpu over [90%] exec [command] msg [xxx]
|
||||
// if process [name] start, kill_it, msg [xxx]
|
||||
// if process [name] start, soundplay [ ], msg [xxx]
|
||||
|
||||
class watchCond
|
||||
{
|
||||
public:
|
||||
int cond;
|
||||
int enable;
|
||||
int cpu;
|
||||
QString procname;
|
||||
QString command;
|
||||
QString message;
|
||||
|
||||
watchCond()
|
||||
{
|
||||
enable = 0;
|
||||
// procname[0]=0; command[0]=0;
|
||||
// message[0]=0;
|
||||
}
|
||||
// key [txt] [a]
|
||||
// QString getVal(QString &str, QString &key)
|
||||
QString getVal(QString &str, const char *key);
|
||||
QString getstring();
|
||||
void putstring(QString str);
|
||||
};
|
||||
|
||||
#endif // WATCHCOND_H
|
||||
|
@ -0,0 +1,239 @@
|
||||
// watchdialog.h
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#include "watchdogdialog.h"
|
||||
|
||||
#include "listmodel.h"
|
||||
#include "checkboxdelegate.h"
|
||||
#include "misc.h" // TBloon class
|
||||
#include "qps.h"
|
||||
#include "watchcond.h"
|
||||
|
||||
#include <QShowEvent>
|
||||
|
||||
extern QList<watchCond *> watchlist;
|
||||
extern Qps *qps;
|
||||
|
||||
WatchdogDialog::WatchdogDialog()
|
||||
{
|
||||
setupUi(this);
|
||||
listmodel = new ListModel();
|
||||
|
||||
tableView->setModel(listmodel);
|
||||
checkBoxDelegate delegate;
|
||||
tableView->setEditTriggers(QAbstractItemView::SelectedClicked);
|
||||
/// tableView->setItemDelegate(&delegate);
|
||||
|
||||
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
QHeaderView *h = tableView->verticalHeader();
|
||||
h->setVisible(false);
|
||||
|
||||
QHeaderView *v = tableView->horizontalHeader();
|
||||
#if QT_VERSION >= 0x050000
|
||||
v->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
v->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
// v->setClickable (false);
|
||||
connect(newButton, SIGNAL(clicked()), this, SLOT(_new()));
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(apply()));
|
||||
connect(addButton, SIGNAL(clicked()), this, SLOT(add()));
|
||||
connect(delButton, SIGNAL(clicked()), this, SLOT(del()));
|
||||
connect(comboBox, SIGNAL(activated(int)), SLOT(comboChanged(int)));
|
||||
connect(comboBox, SIGNAL(highlighted(const QString &)),
|
||||
SLOT(condChanged(const QString &)));
|
||||
|
||||
connect(tableView, SIGNAL(clicked(const QModelIndex &)),
|
||||
SLOT(eventcat_slected(const QModelIndex &)));
|
||||
connect(message, SIGNAL(textEdited(const QString &)),
|
||||
SLOT(Changed(const QString &)));
|
||||
connect(command, SIGNAL(textEdited(const QString &)),
|
||||
SLOT(Changed(const QString &)));
|
||||
connect(proc_name, SIGNAL(textEdited(const QString &)),
|
||||
SLOT(Changed(const QString &)));
|
||||
connect(comboBox, SIGNAL(activated(const QString &)),
|
||||
SLOT(Changed(const QString &)));
|
||||
|
||||
checkBox_alreadyrun->hide();
|
||||
listView->hide();
|
||||
spinBox->hide();
|
||||
label_cpu->hide();
|
||||
/// printf("close ...\n");
|
||||
// tableView->update();
|
||||
// listmodel->update(); // meaningless..
|
||||
|
||||
TBloon *bloon = new TBloon(this);
|
||||
return;
|
||||
}
|
||||
|
||||
void WatchdogDialog::showEvent(QShowEvent *event)
|
||||
{
|
||||
// Qt 4.4.0 bug?
|
||||
// printf("show!!!!!!!!!\n");
|
||||
listmodel->update();
|
||||
}
|
||||
void WatchdogDialog::comboChanged(int idx)
|
||||
{
|
||||
|
||||
// itemText(idx);
|
||||
QString str = comboBox->currentText();
|
||||
|
||||
if (str.contains("cpu"))
|
||||
{
|
||||
label_cpu->show();
|
||||
spinBox->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
spinBox->hide();
|
||||
label_cpu->hide();
|
||||
}
|
||||
|
||||
if (str.contains("process"))
|
||||
{
|
||||
label_procname->show();
|
||||
proc_name->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
label_procname->hide();
|
||||
proc_name->hide();
|
||||
}
|
||||
|
||||
if (message->text().isEmpty())
|
||||
{
|
||||
// if(str.contains("start")) message->setText("%CMD start
|
||||
// with pid %PID");
|
||||
// if(str.contains("finish")) message->setText("%CMD
|
||||
// finish with pid
|
||||
//%PID");
|
||||
}
|
||||
}
|
||||
|
||||
void WatchdogDialog::eventcat_slected(const QModelIndex &idx)
|
||||
{
|
||||
|
||||
watchCond *w = watchlist[idx.row()];
|
||||
// printf("row=%d\n",at=idx.row());
|
||||
|
||||
if (idx.column() == 1)
|
||||
{
|
||||
w->enable = !(w->enable);
|
||||
listmodel->update(idx.row());
|
||||
return;
|
||||
}
|
||||
|
||||
QString str = idx.data().toString(); // Qt::DisplayRol
|
||||
|
||||
if (str.contains("process"))
|
||||
proc_name->setText(w->procname);
|
||||
else
|
||||
proc_name->setText("");
|
||||
if (str.contains("cpu"))
|
||||
spinBox->setSingleStep(w->cpu);
|
||||
else
|
||||
spinBox->setSingleStep(50);
|
||||
if (str.contains("exec"))
|
||||
command->setText(w->command);
|
||||
else
|
||||
command->setText("");
|
||||
if (str.contains("showmsg"))
|
||||
message->setText(w->message);
|
||||
else
|
||||
message->setText("");
|
||||
|
||||
checkCombo();
|
||||
comboBox->setCurrentIndex(w->cond);
|
||||
}
|
||||
|
||||
void WatchdogDialog::Changed(const QString &str)
|
||||
{
|
||||
QModelIndex idx = tableView->currentIndex();
|
||||
// QModelIndexList list=tableView->selectedIndexes ();
|
||||
bool flag = tableView->selectionModel()->hasSelection();
|
||||
// if(list.count() and idx.isValid())
|
||||
if (flag and idx.isValid())
|
||||
{
|
||||
int at = idx.row();
|
||||
watchCond *w = watchlist[at];
|
||||
w->message = message->text();
|
||||
w->command = command->text();
|
||||
w->procname = proc_name->text();
|
||||
w->cond = comboBox->currentIndex();
|
||||
listmodel->update(at);
|
||||
// watchlist.removeAt(at);
|
||||
}
|
||||
// listmodel->update();
|
||||
}
|
||||
|
||||
void WatchdogDialog::checkCombo()
|
||||
{
|
||||
if (comboBox->count() == 1)
|
||||
{
|
||||
comboBox->clear();
|
||||
comboBox->addItem("if process start");
|
||||
comboBox->addItem("if process finish");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// comboChanged() -> checkCombo()
|
||||
void WatchdogDialog::condChanged(const QString &str)
|
||||
{
|
||||
checkCombo();
|
||||
// what is this?
|
||||
// printf("chagend\n");
|
||||
// comboBox->currentText();
|
||||
// command->text();
|
||||
// message->text();
|
||||
}
|
||||
|
||||
void WatchdogDialog::_new()
|
||||
{
|
||||
tableView->clearSelection();
|
||||
proc_name->clear();
|
||||
command->clear();
|
||||
message->clear();
|
||||
comboBox->clear();
|
||||
comboBox->addItem("select condition");
|
||||
}
|
||||
|
||||
void WatchdogDialog::add()
|
||||
{
|
||||
watchCond *w = new watchCond;
|
||||
w->enable = true;
|
||||
w->cond = comboBox->currentIndex();
|
||||
w->command = command->text();
|
||||
w->message = message->text();
|
||||
w->procname = proc_name->text();
|
||||
watchlist.append(w);
|
||||
// listView->update(QModelIndex());
|
||||
// listView->reset();
|
||||
// tableView->reset();
|
||||
// listmodel->insertRow(listmodel->rowCount(QModelIndex()));
|
||||
// tableView->update(QModelIndex());
|
||||
// tableView->dataChanged(QModelIndex(),QModelIndex()); //protected
|
||||
listmodel->update();
|
||||
}
|
||||
|
||||
void WatchdogDialog::del()
|
||||
{
|
||||
// QModelIndex idx=listView->currentIndex();
|
||||
QModelIndex idx = tableView->currentIndex();
|
||||
if (idx.isValid())
|
||||
{
|
||||
int at = idx.row();
|
||||
watchlist.removeAt(at);
|
||||
}
|
||||
listmodel->update();
|
||||
tableView->setCurrentIndex(idx);
|
||||
}
|
||||
|
||||
void WatchdogDialog::apply()
|
||||
{
|
||||
qps->write_settings();
|
||||
close();
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
// watchdogdialog.cpp
|
||||
//
|
||||
// This program is free software. See the file COPYING for details.
|
||||
// Author: Mattias Engdeg?rd, 1997-1999
|
||||
|
||||
#ifndef WATCHDOGDIALOG_H
|
||||
#define WATCHDOGDIALOG_H
|
||||
|
||||
#include "ui_watchdog.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QModelIndex>
|
||||
#include <QString>
|
||||
|
||||
class ListModel;
|
||||
class QShowEvent;
|
||||
|
||||
class WatchdogDialog : public QDialog, private Ui_EventDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WatchdogDialog();
|
||||
ListModel *listmodel;
|
||||
// signals:
|
||||
// void command_change();
|
||||
void checkCombo();
|
||||
protected slots:
|
||||
void _new();
|
||||
void apply();
|
||||
void add();
|
||||
void del();
|
||||
void condChanged(const QString &str);
|
||||
void Changed(const QString &str);
|
||||
|
||||
void comboChanged(int);
|
||||
void eventcat_slected(const QModelIndex &idx);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
||||
// void set_select( const QModelIndex & );
|
||||
// void event_name_midified(const QString &new_name);
|
||||
// void event_cmd_modified();
|
||||
// void event_toolbar_checked(bool);
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // WATCHDOGDIALOG_H
|
Loading…
Reference in new issue