80
src/qbrowserlib/buttonlineedit.hxx
Normal file
80
src/qbrowserlib/buttonlineedit.hxx
Normal file
@@ -0,0 +1,80 @@
|
||||
/*! @file
|
||||
|
||||
@id $Id$
|
||||
*/
|
||||
// 1 2 3 4 5 6 7 8
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
#ifndef __BUTTONLINEEDIT_HXX__
|
||||
#define __BUTTONLINEEDIT_HXX__
|
||||
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#ifndef LOG
|
||||
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
||||
#endif
|
||||
|
||||
//! @addtogroup qbrowserlib
|
||||
//! @{
|
||||
|
||||
//! A QLineEdit that may have buttons to the right within the lineedit.
|
||||
class ButtonLineEdit: public QLineEdit {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
ButtonLineEdit(QWidget* p=0): QLineEdit(p) {
|
||||
LOG;
|
||||
}
|
||||
QToolButton* add(QAction* a) {
|
||||
LOG;
|
||||
QToolButton* b(new QToolButton(this));
|
||||
b->setDefaultAction(a);
|
||||
add(b);
|
||||
return b;
|
||||
}
|
||||
ButtonLineEdit& add(QToolButton* b) {
|
||||
LOG;
|
||||
b->setParent(this);
|
||||
b->setStyleSheet("QToolButton { border: none; padding: 0; }");
|
||||
b->setCursor(Qt::ArrowCursor);
|
||||
_buttons.push_back(b);
|
||||
resizeEvent(0);
|
||||
return *this;
|
||||
}
|
||||
ButtonLineEdit& changeStyleSheet(QString s) {
|
||||
LOG;
|
||||
_style = s;
|
||||
resizeEvent(0);
|
||||
return *this;
|
||||
}
|
||||
static void foreachActionWidget(QAction& a, void(QWidget::*f)()) {
|
||||
QList<QWidget*> widgets(a.associatedWidgets());
|
||||
for (QList<QWidget*>::iterator w(widgets.begin()); w!=widgets.end(); ++w)
|
||||
((*w)->*f)();
|
||||
}
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent*) {
|
||||
QSize sz;
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
for (Buttons::iterator it(_buttons.begin());
|
||||
it!=_buttons.end(); ++it) {
|
||||
if (sz.isEmpty()) sz = (*it)->sizeHint();
|
||||
else sz.setWidth(sz.width()+(*it)->sizeHint().width());
|
||||
(*it)->move(rect().right() - frameWidth - sz.width(),
|
||||
(rect().bottom() + 1 - (*it)->sizeHint().height())/2);
|
||||
}
|
||||
setStyleSheet(QString("QLineEdit { padding-right: %1px; %2 }")
|
||||
.arg(sz.width() + frameWidth + 1)
|
||||
.arg(_style));
|
||||
}
|
||||
private:
|
||||
typedef QList<QToolButton*> Buttons;
|
||||
Buttons _buttons;
|
||||
QString _style;
|
||||
};
|
||||
|
||||
//! @}
|
||||
#endif
|
@@ -80,7 +80,7 @@ install-data-local:
|
||||
${INSTALL} ${QMAKE_TARGET}* ${DESTDIR}${libdir}
|
||||
|
||||
uninstall-local:
|
||||
rm -r ${DESTDIR}${libdir}/${QMAKE_TARGET}*
|
||||
-rm -r ${DESTDIR}${libdir}/${QMAKE_TARGET}*
|
||||
|
||||
clean-local:
|
||||
-rm -r ${QMAKE_TARGET}*
|
||||
|
@@ -19,6 +19,8 @@
|
||||
//! @addtogroup qbrowserlib
|
||||
//! @{
|
||||
|
||||
//! Handle PDF Documents
|
||||
/*! */
|
||||
class PluginFactory: public QWebPluginFactory {
|
||||
public:
|
||||
PluginFactory(QObject* p=0): QWebPluginFactory(p) {
|
||||
|
@@ -36,8 +36,9 @@ TRANSLATIONS = @srcdir@/qbrowserlib_en.ts \
|
||||
|
||||
SOURCES =
|
||||
|
||||
HEADERS = @srcdir@/swisswebview.hxx @srcdir@/swisswebpage.hxx \
|
||||
@srcdir@/pluginfactory.hxx @srcdir@/saveorrun.hxx
|
||||
HEADERS = @srcdir@/swisswebview.hxx @srcdir@/swisswebpage.hxx \
|
||||
@srcdir@/pluginfactory.hxx @srcdir@/saveorrun.hxx \
|
||||
@srcdir@/buttonlineedit.hxx
|
||||
|
||||
FORMS = @srcdir@/saveorrun.ui
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
//! @addtogroup qbrowserlib
|
||||
//! @{
|
||||
|
||||
//! Ask User for Saving or Opening a Download
|
||||
class SaveOrRun: public QWidget, public Ui::SaveOrRun {
|
||||
Q_OBJECT;
|
||||
|
||||
|
Reference in New Issue
Block a user