Commit 5d6ef51e authored by Philipp Erhardt's avatar Philipp Erhardt
Browse files

Fix splitter and canvas transparency

parent 7647ba06
......@@ -13,11 +13,11 @@ QMAKE_CXXFLAGS_DEBUG += -DDEBUG
# Input
HEADERS += src/layout/layout.h src/layout/presentationlayout.h src/layout/gridlayout.h src/layout/presenterlayout.h \
src/viewer.h src/canvas.h src/resourcemanager.h src/grid.h src/search.h src/gotoline.h src/config.h src/download.h src/util.h src/kpage.h src/worker.h src/beamerwindow.h src/toc.h
src/viewer.h src/canvas.h src/resourcemanager.h src/grid.h src/search.h src/gotoline.h src/config.h src/download.h src/util.h src/kpage.h src/worker.h src/beamerwindow.h src/toc.h src/splitter.h
SOURCES += src/main.cpp \
src/layout/layout.cpp src/layout/presentationlayout.cpp src/layout/gridlayout.cpp src/layout/presenterlayout.cpp \
src/viewer.cpp src/canvas.cpp src/resourcemanager.cpp src/grid.cpp src/search.cpp src/gotoline.cpp src/config.cpp src/download.cpp src/util.cpp src/kpage.cpp src/worker.cpp src/beamerwindow.cpp src/toc.cpp
src/viewer.cpp src/canvas.cpp src/resourcemanager.cpp src/grid.cpp src/search.cpp src/gotoline.cpp src/config.cpp src/download.cpp src/util.cpp src/kpage.cpp src/worker.cpp src/beamerwindow.cpp src/toc.cpp src/splitter.cpp
unix:LIBS += -lpoppler-qt4
documentation.target = doc/katarakt.1
......
#include "splitter.h"
SplitterHandle::SplitterHandle(Qt::Orientation orientation, QSplitter *parent) :
QSplitterHandle(orientation, parent) {
}
void SplitterHandle::paintEvent(QPaintEvent *event) {
QPainter painter(this);
// draw background
// couldn't find another way to make the contents of a splitter transparent, but not the splitter itself
painter.fillRect(rect(), QApplication::palette().window());
// draw handle
QSplitterHandle::paintEvent(event);
}
Splitter::Splitter(QWidget *parent) :
QSplitter(parent) {
}
Splitter::Splitter(Qt::Orientation orientation, QWidget *parent) :
QSplitter(orientation, parent) {
}
QSplitterHandle *Splitter::createHandle() {
return new SplitterHandle(orientation(), this);
}
#ifndef SPLITTER_H
#define SPLITTER_H
#include <QSplitter>
#include <QSplitterHandle>
#include <QPaintEvent>
#include <QApplication>
#include <QPainter>
class SplitterHandle : public QSplitterHandle {
Q_OBJECT
public:
SplitterHandle(Qt::Orientation orientation, QSplitter *parent);
protected:
void paintEvent(QPaintEvent *event);
};
class Splitter : public QSplitter {
Q_OBJECT
public:
Splitter(QWidget *parent = 0);
Splitter(Qt::Orientation orientation, QWidget *parent = 0);
protected:
QSplitterHandle *createHandle();
};
#endif
......@@ -3,7 +3,6 @@
#include <QFileInfo>
#include <QAction>
#include <QFileDialog>
#include <QSplitter>
#include <csignal>
#include <cerrno>
#include <unistd.h>
......@@ -15,6 +14,7 @@
#include "layout/layout.h"
#include "beamerwindow.h"
#include "toc.h"
#include "splitter.h"
#include "util.h"
using namespace std;
......@@ -76,7 +76,7 @@ Viewer::Viewer(const QString &file, QWidget *parent) :
beamer = new BeamerWindow(this);
setup_keys(beamer);
splitter = new QSplitter(this);
splitter = new Splitter(this);
toc = new Toc(this, splitter);
canvas = new Canvas(this, splitter); // beamer must already exist
......@@ -86,7 +86,6 @@ Viewer::Viewer(const QString &file, QWidget *parent) :
}
res->connect_canvas();
splitter->setAutoFillBackground(true);
splitter->addWidget(toc);
splitter->addWidget(canvas);
splitter->setSizes(QList<int>() << (width() / 4) << (width() * 3 / 4)); // TODO config option
......@@ -146,6 +145,13 @@ Viewer::Viewer(const QString &file, QWidget *parent) :
setAttribute(Qt::WA_TranslucentBackground);
search_bar->setAutoFillBackground(true);
info_widget.setAutoFillBackground(true);
toc->setAutoFillBackground(true);
// the splitter handle has to be opaque, canvas has to be transparent
// problem: either both are transparent or none is
// these functions don't help, the splitter handle is still transparent (depending on theme)
// splitter->handle(0)->setAttribute(Qt::WA_TranslucentBackground, false);
// splitter->handle(0)->setBackgroundRole(QPalette::Window);
// splitter->handle(0)->setAutoFillBackground(true);
}
Viewer::~Viewer() {
......
......@@ -13,7 +13,7 @@ class ResourceManager;
class Canvas;
class SearchBar;
class BeamerWindow;
class QSplitter;
class Splitter;
class Toc;
......@@ -77,10 +77,9 @@ private slots:
private:
void update_info_widget();
void setup_keys(QWidget *base);
// void add_action(QWidget *base, const char *action, const char *slot, bool base_is_target = false);
ResourceManager *res;
QSplitter *splitter;
Splitter *splitter;
Toc *toc;
Canvas *canvas;
SearchBar *search_bar;
......
Supports Markdown
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