Barra de direcciones completada.

git-svn-id: https://opengnsys.es/svn/trunk@475 a21b9725-9963-47de-94b9-378ad31fedc9
remotes/github/master
adelcastillo 2009-11-02 22:13:34 +00:00
parent 55d467e09b
commit 2e2ba31a55
3 changed files with 63 additions and 7 deletions

View File

@ -29,6 +29,8 @@ add_executable(browser ${browser_SRCS})
target_link_libraries(browser qtermwidget ${QT_QTWEBKIT_LIBRARIES} ) target_link_libraries(browser qtermwidget ${QT_QTWEBKIT_LIBRARIES} )
# set(CMAKE_CXX_FLAGS "-static")
foreach(QT ${QT_LIBRARIES}) foreach(QT ${QT_LIBRARIES})
message("${QT}") message("${QT}")
endforeach(QT) endforeach(QT)

View File

@ -12,6 +12,7 @@
#include <QDateTime> #include <QDateTime>
#include <QProgressBar> #include <QProgressBar>
#include <QTabWidget> #include <QTabWidget>
#include <QLineEdit>
#include "qtermwidget.h" #include "qtermwidget.h"
@ -36,7 +37,7 @@ MainWindow::MainWindow(QWidget *parent)
// Output // Output
output->setReadOnly(true); output->setReadOnly(true);
// Dock // Button Dock
QDockWidget* dock=new QDockWidget(); QDockWidget* dock=new QDockWidget();
dock->setAllowedAreas(Qt::BottomDockWidgetArea); dock->setAllowedAreas(Qt::BottomDockWidgetArea);
QWidget* dummy=new QWidget(); QWidget* dummy=new QWidget();
@ -46,7 +47,9 @@ MainWindow::MainWindow(QWidget *parent)
// TabWidget // TabWidget
tabs=new QTabWidget(dock); tabs=new QTabWidget(dock);
QPushButton *button=new QPushButton(tr("&New Term")); QPushButton *button=new QPushButton(tr("&New Term"));
button->setFocusPolicy(Qt::TabFocus);
tabs->setCornerWidget(button); tabs->setCornerWidget(button);
tabs->setFocusPolicy(Qt::NoFocus);
tabs->addTab(output,tr("Output")); tabs->addTab(output,tr("Output"));
slotCreateTerminal(); slotCreateTerminal();
@ -57,6 +60,22 @@ MainWindow::MainWindow(QWidget *parent)
// Y el dock al mainwindow // Y el dock al mainwindow
addDockWidget(Qt::BottomDockWidgetArea,dock); addDockWidget(Qt::BottomDockWidgetArea,dock);
// Top Dock
dock=new QDockWidget();
dock->setAllowedAreas(Qt::TopDockWidgetArea);
QWidget* dummy2=new QWidget();
dummy2->setMaximumHeight(0);
dock->setTitleBarWidget(dummy2);
// WebBar
webBar=new QLineEdit(dock);
// WebBar al dock
dock->setWidget(webBar);
// dock al mainwindow
addDockWidget(Qt::TopDockWidgetArea,dock);
// Status bar // Status bar
QStatusBar* st=statusBar(); QStatusBar* st=statusBar();
st->setSizeGripEnabled(false); st->setSizeGripEnabled(false);
@ -67,15 +86,13 @@ MainWindow::MainWindow(QWidget *parent)
web->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); web->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
// Web signals // Web signals
connect(web->page(),SIGNAL(linkClicked(const QUrl&)),this, connect(web,SIGNAL(linkClicked(const QUrl&)),this,
SLOT(slotLinkHandle(const QUrl&))); SLOT(slotLinkHandle(const QUrl&)));
connect(web,SIGNAL(loadStarted()),this,SLOT(slotWebLoadStarted())); connect(web,SIGNAL(loadStarted()),this,SLOT(slotWebLoadStarted()));
connect(web,SIGNAL(loadFinished(bool)),this,SLOT(slotWebLoadFinished(bool))); connect(web,SIGNAL(loadFinished(bool)),this,SLOT(slotWebLoadFinished(bool)));
connect(web,SIGNAL(loadProgress(int)),this,SLOT(slotWebLoadProgress(int))); connect(web,SIGNAL(loadProgress(int)),this,SLOT(slotWebLoadProgress(int)));
connect(web,SIGNAL(urlChanged(const QUrl&)),this,
QStringList arguments=QCoreApplication::arguments(); SLOT(slotUrlChanged(const QUrl&)));
web->load(QUrl(arguments[1]));
// Process signals // Process signals
connect(process,SIGNAL(started()),this,SLOT(slotProcessStarted())); connect(process,SIGNAL(started()),this,SLOT(slotProcessStarted()));
@ -89,7 +106,9 @@ MainWindow::MainWindow(QWidget *parent)
connect(process,SIGNAL(readyReadStandardError()), connect(process,SIGNAL(readyReadStandardError()),
this,SLOT(slotProcessErrorOutput())); this,SLOT(slotProcessErrorOutput()));
// Dock signals
connect(button,SIGNAL(clicked()),this,SLOT(slotCreateTerminal())); connect(button,SIGNAL(clicked()),this,SLOT(slotCreateTerminal()));
connect(webBar,SIGNAL(returnPressed()),this,SLOT(slotWebBarReturnPressed()));
if(!readEnvironmentValues()) if(!readEnvironmentValues())
output->insertPlainText(tr("Any environment variable/s didn't be setted\n")); output->insertPlainText(tr("Any environment variable/s didn't be setted\n"));
@ -107,6 +126,10 @@ MainWindow::MainWindow(QWidget *parent)
else else
logstream=new QTextStream(logfile); logstream=new QTextStream(logfile);
} }
QStringList arguments=QCoreApplication::arguments();
webBar->setText(arguments[1]);
web->load(QUrl(arguments[1]));
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -201,6 +224,13 @@ void MainWindow::slotWebLoadFinished(bool ok)
} }
} }
void MainWindow::slotUrlChanged(const QUrl &url)
{
webBar->setText(url.toString());
qDebug()<<"Change"<<endl;
}
void MainWindow::slotProcessStarted() void MainWindow::slotProcessStarted()
{ {
qDebug()<<"Proceso inicializado"<<endl; qDebug()<<"Proceso inicializado"<<endl;
@ -272,22 +302,39 @@ void MainWindow::slotProcessError(QProcess::ProcessError error)
void MainWindow::slotCreateTerminal() void MainWindow::slotCreateTerminal()
{ {
QTermWidget* console = new QTermWidget(); QTermWidget* console = new QTermWidget(1,this);
QFont font = QApplication::font(); QFont font = QApplication::font();
font.setFamily("Terminus"); font.setFamily("Terminus");
font.setPointSize(12); font.setPointSize(12);
console->setTerminalFont(font); console->setTerminalFont(font);
console->setFocusPolicy(Qt::StrongFocus);
//console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW); //console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW);
console->setScrollBarPosition(QTermWidget::ScrollBarRight); console->setScrollBarPosition(QTermWidget::ScrollBarRight);
++numberTerminal; ++numberTerminal;
connect(console,SIGNAL(finished()),this,SLOT(slotDeleteTerminal()));
QString name=tr("Term ")+QString::number(numberTerminal); QString name=tr("Term ")+QString::number(numberTerminal);
tabs->addTab(console,name); tabs->addTab(console,name);
} }
void MainWindow::slotDeleteTerminal()
{
QWidget *widget = qobject_cast<QWidget *>(sender());
Q_ASSERT(widget);
tabs->removeTab(tabs->indexOf(widget));
}
void MainWindow::slotWebBarReturnPressed()
{
QUrl url(webBar->text());
if(url.isValid())
slotLinkHandle(url);
}
int MainWindow::readEnvironmentValues() int MainWindow::readEnvironmentValues()
{ {
// The return value // The return value

View File

@ -21,6 +21,7 @@ class QFile;
class QTextStream; class QTextStream;
class QTermWidget; class QTermWidget;
class QProgressBar; class QProgressBar;
class QLineEdit;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
@ -46,6 +47,11 @@ class MainWindow : public QMainWindow
// Funcion para crear terminales // Funcion para crear terminales
void slotCreateTerminal(); void slotCreateTerminal();
void slotDeleteTerminal();
// Funcion para el webar
void slotWebBarReturnPressed();
void slotUrlChanged(const QUrl &url);
//Functions //Functions
protected: protected:
@ -57,6 +63,7 @@ class MainWindow : public QMainWindow
QTextEdit *output; QTextEdit *output;
QProgressBar *progressBar; QProgressBar *progressBar;
QTabWidget *tabs; QTabWidget *tabs;
QLineEdit *webBar;
QProcess *process; QProcess *process;