Commit fcebd431 authored by Dirk Wilden's avatar Dirk Wilden

helpWidget now nearly perfect :D

added Tabs and search functionality

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@3643 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ba856319
......@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
......@@ -45,34 +45,50 @@
#include <OpenFlipper/common/GlobalOptions.hh>
//== IMPLEMENTATION ==========================================================
//== IMPLEMENTATION ==========================================================
void CoreWidget::showHelpBrowserUser( ) {
if ( OpenFlipper::Options::nogui() )
return;
if ( helpBrowserUser_ == 0 ) {
helpBrowserUser_ = new HelpWidget( this ,true);
}
//show the widget centered
QPoint center;
center.setX( x() + width() / 2 );
center.setY( y() + height() / 2 );
helpBrowserUser_->setGeometry(center.x() - helpBrowserUser_->width() / 2,
center.y() - helpBrowserUser_->height()/ 2, helpBrowserUser_->width(), helpBrowserUser_->height());
helpBrowserUser_->show();
}
void CoreWidget::showHelpBrowserDeveloper( ) {
if ( OpenFlipper::Options::nogui() )
return;
if ( helpBrowserDeveloper_ == 0 ) {
helpBrowserDeveloper_ = new HelpWidget( this ,false);
}
//show the widget centered
QPoint center;
center.setX( x() + width() / 2 );
center.setY( y() + height() / 2 );
helpBrowserDeveloper_->setGeometry(center.x() - helpBrowserDeveloper_->width() / 2,
center.y() - helpBrowserDeveloper_->height()/ 2, helpBrowserDeveloper_->width(), helpBrowserDeveloper_->height());
helpBrowserDeveloper_->show();
}
//=============================================================================
#include "findEdit.hh"
#include <QKeyEvent>
findEdit::findEdit(QWidget* parent) : QLineEdit(parent)
{
connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(slotTextEdited(const QString&)) );
}
void findEdit::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
emit find();
else if (event->key() == Qt::Key_F3)
emit find();
else if (event->key() == Qt::Key_Escape)
emit close();
else
QLineEdit::keyPressEvent(event);
}
void findEdit::slotTextEdited(const QString&)
{
emit textEdited();
}
#ifndef FINDEDIT_HH
#define FINDEDIT_HH
#include <QLineEdit>
class findEdit : public QLineEdit
{
Q_OBJECT
signals:
void find();
void close();
void textEdited();
public:
findEdit(QWidget *parent = 0);
protected:
void keyPressEvent( QKeyEvent* event );
private slots:
void slotTextEdited(const QString& /*text*/);
};
#endif //FINDEDIT_HH
This diff is collapsed.
#include "ui_helpWidget.hh"
#include <QtGui>
#include "webView.hh"
#include "findEdit.hh"
class HelpWidget : public QMainWindow, public Ui::HelpWidget
{
Q_OBJECT
......@@ -14,12 +17,44 @@ class HelpWidget : public QMainWindow, public Ui::HelpWidget
void generateTree();
void setConnections();
QString getTitle(QString htmlFile);
QAction* back_;
QAction* forward_;
webView* currentView_;
private slots:
void loadFinished( bool ok );
void loadFinished( bool ok );
void goHome();
void treeClicked(QTreeWidgetItem* item, int column );
void urlChanged(const QUrl& url);
void newTab(QWebView* _webView);
void titleChanged (const QString & title );
void tabChanged (int _index);
void closeCurrentTab();
void duplicateCurrentTab();
//finding
private:
findEdit* findText_;
private slots:
void showFind();
void findNext1();
void findPrev1();
void initFindFrame();
//context menu
private:
QMenu* contextMenu_;
QPoint lastContextMenu_;
private slots:
void showContextMenu(const QPoint& _pos);
void contextOpenTab();
void contextOpenNewTab();
void contextCloseTab();
};
......@@ -5,97 +5,178 @@
<rect>
<x>0</x>
<y>0</y>
<width>1008</width>
<height>813</height>
<width>805</width>
<height>680</height>
</rect>
</property>
<property name="windowTitle" >
<string>Help Browser</string>
</property>
<widget class="QWidget" name="centralwidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>35</y>
<width>1008</width>
<height>757</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QTreeWidget" name="tree" >
<property name="minimumSize" >
<size>
<width>160</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>818</width>
<height>677</height>
</rect>
</property>
<attribute name="title" >
<string>Tab 1</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QWebView" name="webView" >
<property name="sizePolicy" >
<sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="url" >
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closeButton" >
<widget class="QSplitter" name="splitter" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeWidget" name="tree" >
<property name="sizePolicy" >
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Ignored" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text" >
<string>Close</string>
<string>1</string>
</property>
</column>
</widget>
<widget class="QWidget" name="" >
<layout class="QVBoxLayout" name="verticalLayout" >
<property name="sizeConstraint" >
<enum>QLayout::SetDefaultConstraint</enum>
</property>
</widget>
</item>
</layout>
<item>
<widget class="QTabWidget" name="tabs" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Ignored" hsizetype="Ignored" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="baseSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<string>Tab 1</string>
</attribute>
</widget>
</widget>
</item>
<item>
<widget class="QFrame" name="findFrame" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<widget class="QPushButton" name="findNext" >
<property name="geometry" >
<rect>
<x>222</x>
<y>4</y>
<width>53</width>
<height>24</height>
</rect>
</property>
<property name="text" >
<string>Next</string>
</property>
<property name="flat" >
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="findClose" >
<property name="geometry" >
<rect>
<x>4</x>
<y>4</y>
<width>24</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>25</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="flat" >
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="findPrev" >
<property name="geometry" >
<rect>
<x>146</x>
<y>4</y>
<width>72</width>
<height>24</height>
</rect>
</property>
<property name="text" >
<string>Previous</string>
</property>
<property name="flat" >
<bool>false</bool>
</property>
</widget>
<widget class="QCheckBox" name="findSensitive" >
<property name="geometry" >
<rect>
<x>279</x>
<y>5</y>
<width>96</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Case Sensitive</string>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
......@@ -104,8 +185,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1008</width>
<height>21</height>
<width>805</width>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
......@@ -116,25 +197,8 @@
</widget>
<addaction name="menuFile" />
</widget>
<widget class="QStatusBar" name="statusbar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>792</y>
<width>1008</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar" />
<widget class="QToolBar" name="toolBar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>21</y>
<width>1008</width>
<height>14</height>
</rect>
</property>
<property name="windowTitle" >
<string>toolBar</string>
</property>
......@@ -151,13 +215,14 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabs</tabstop>
<tabstop>tree</tabstop>
<tabstop>findNext</tabstop>
<tabstop>findClose</tabstop>
<tabstop>findPrev</tabstop>
<tabstop>findSensitive</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
#include "webView.hh"
#include <QKeyEvent>
webView::webView(QWidget * parent) : QWebView(parent)
{
}
QWebView* webView::createWindow(QWebPage::WebWindowType /*type*/)
{
webView* window = new webView();
emit windowCreated(window);
return window;
}
void webView::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_F && event->modifiers() == Qt::ControlModifier)
emit find();
else if (event->key() == Qt::Key_F3)
emit findNext();
else
QWebView::keyPressEvent(event);
}
#ifndef WEBVIEW_HH
#define WEBVIEW_HH
#include "ui_helpWidget.hh"
#include <QtWebKit>
class webView : public QWebView
{
Q_OBJECT
signals:
void windowCreated(QWebView* _webView);
void find();
void findNext();
public:
webView(QWidget *parent = 0);
protected:
QWebView* createWindow( QWebPage::WebWindowType type );
void keyPressEvent( QKeyEvent* event );
};
#endif //WEBVIEW_HH
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment