summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filestreewidget.cpp1
-rw-r--r--filestreewidget.h1
-rw-r--r--hoverwindow.cpp41
-rw-r--r--hoverwindow.h26
-rw-r--r--seriestreewidget.cpp42
-rw-r--r--seriestreewidget.h15
-rw-r--r--shemov.pro6
-rw-r--r--smglobals.cpp15
-rw-r--r--smglobals.h2
9 files changed, 96 insertions, 53 deletions
diff --git a/filestreewidget.cpp b/filestreewidget.cpp
index 4542ea8..a941612 100644
--- a/filestreewidget.cpp
+++ b/filestreewidget.cpp
@@ -29,6 +29,7 @@
#include "helper.h"
#include "pictureviewer.h"
#include "filepropertiesdialog.h"
+#include "hoverwindow.h"
FilesTreeWidget::FilesTreeWidget(QWidget *parent) : QWidget(parent), mSelectedSize(0){
//the view
diff --git a/filestreewidget.h b/filestreewidget.h
index 86686ca..c340020 100644
--- a/filestreewidget.h
+++ b/filestreewidget.h
@@ -18,6 +18,7 @@ class FilesTreeModel;
class FilesTreeSortModel;
class SeriesTreeModel;
class PictureViewer;
+class HoverWindow;
class QContextMenuEvent;
class QSpinBox;
class QPushButton;
diff --git a/hoverwindow.cpp b/hoverwindow.cpp
new file mode 100644
index 0000000..59c851e
--- /dev/null
+++ b/hoverwindow.cpp
@@ -0,0 +1,41 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#include <QHBoxLayout>
+#include <QLabel>
+
+#include "hoverwindow.h"
+
+HoverWindow::HoverWindow(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){
+ setVisible(false);
+ setWindowOpacity(0.7);
+ setStyleSheet("QLabel { background-color: #D6A583; color: black; border-width: 2px; border-style: solid; padding: 4px; }");
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->setContentsMargins(4, 4, 4, 4);
+ mLabel = new QLabel;
+ mainLayout->addWidget(mLabel);
+ setLayout(mainLayout);
+}
+
+void HoverWindow::setContent(const QString &parent, const QStringList &children){
+ QString curText = QString("<p style=\"align: center; text-decoration: underline; font-weight: bold; margin-bottom: 0;\">%1</p>").arg(parent);
+ curText.append("<ul style=\"margin-left: -25; margin-top: 0px;\">");
+ int count = qMin(6, children.size());
+ int i = 0;
+ for(i = 0; i < count; ++i){
+ curText.append(QString("<li>%1</li>").arg(children.at(i)));
+ }
+ if(i < children.count()){
+ curText.append("<li>...</li>");
+ }
+ curText.append("</ul>");
+ mLabel->setText(curText);
+}
+
+void HoverWindow::setPixmap(const QPixmap &pm){
+ mLabel->setPixmap(pm);
+}
diff --git a/hoverwindow.h b/hoverwindow.h
new file mode 100644
index 0000000..b020124
--- /dev/null
+++ b/hoverwindow.h
@@ -0,0 +1,26 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#ifndef HOVERWINDOW_H
+#define HOVERWINDOW_H
+
+#include <QWidget>
+
+class QLabel;
+
+class HoverWindow : public QWidget {
+ Q_OBJECT
+ public:
+ explicit HoverWindow(QWidget *parent = 0, Qt::WindowFlags f = Qt::FramelessWindowHint);
+ void setContent(const QString &parent, const QStringList &children);
+ void setPixmap(const QPixmap &pm);
+
+ private:
+ QLabel *mLabel;
+};
+
+#endif // HOVERWINDOW_H
diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp
index 791fb9e..b5a3feb 100644
--- a/seriestreewidget.cpp
+++ b/seriestreewidget.cpp
@@ -24,12 +24,6 @@
#include <QFile>
#include <QEvent>
#include <QHoverEvent>
-#include <QPaintEvent>
-#include <QPainter>
-
-#include <QX11Info>
-#include <X11/Xlib.h>
-#include <X11/extensions/Xfixes.h>
#include "seriestreewidget.h"
#include "smtreemodel.h"
@@ -37,6 +31,7 @@
#include "seriestreemodel.h"
#include "filestreemodel.h"
#include "helper.h"
+#include "hoverwindow.h"
SeriesTreeWidget::SeriesTreeWidget(QWidget *parent) : QWidget(parent){
//filter bar
@@ -318,12 +313,9 @@ void SeriesTreeWidget::addCover(){
}
}
-SeriesTreeView::SeriesTreeView(QWidget *parent) : QTreeView(parent), mCursorOffset(0) {
+SeriesTreeView::SeriesTreeView(QWidget *parent) : QTreeView(parent) {
setAttribute(Qt::WA_Hover);
- mHoverWin = new SeriesTreeHoverWindow;
- XFixesCursorImage *curImage = XFixesGetCursorImage(QX11Info::display());
- mCursorOffset = curImage->height;
- XFree(curImage);
+ mHoverWin = new HoverWindow;
}
void SeriesTreeView::contextMenuEvent(QContextMenuEvent *e){
@@ -337,7 +329,7 @@ void SeriesTreeView::contextMenuEvent(QContextMenuEvent *e){
bool SeriesTreeView::event(QEvent *e){
QModelIndex curIdx;
QHoverEvent *hEvent = static_cast<QHoverEvent*>(e);
- QPoint hotSpot(hEvent->pos().x(), hEvent->pos().y() - mCursorOffset);
+ QPoint hotSpot(hEvent->pos().x(), hEvent->pos().y() - SmGlobals::instance()->cursorOffset());
QPoint globalPos = mapToGlobal(hotSpot);
QPoint where = globalPos + QPoint(30, 30);
@@ -393,32 +385,6 @@ QStringList SeriesTreeView::children(const QModelIndex &idx) const{
return retval;
}
-SeriesTreeHoverWindow::SeriesTreeHoverWindow(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){
- setVisible(false);
- setWindowOpacity(0.7);
- setStyleSheet("QLabel { background-color: #D6A583; color: black; border-width: 2px; border-style: solid; padding: 4px; }");
- QHBoxLayout *mainLayout = new QHBoxLayout;
- mainLayout->setContentsMargins(4, 4, 4, 4);
- mLabel = new QLabel;
- mainLayout->addWidget(mLabel);
- setLayout(mainLayout);
-}
-
-void SeriesTreeHoverWindow::setContent(const QString &parent, const QStringList &children){
- QString curText = QString("<p style=\"align: center; text-decoration: underline; font-weight: bold; margin-bottom: 0;\">%1</p>").arg(parent);
- curText.append("<ul style=\"margin-left: -25; margin-top: 0px;\">");
- int count = qMin(6, children.size());
- int i = 0;
- for(i = 0; i < count; ++i){
- curText.append(QString("<li>%1</li>").arg(children.at(i)));
- }
- if(i < children.count()){
- curText.append("<li>...</li>");
- }
- curText.append("</ul>");
- mLabel->setText(curText);
-}
-
SeriesTreeSortModel::SeriesTreeSortModel(QObject *parent) : QSortFilterProxyModel(parent) {}
bool SeriesTreeSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const{
diff --git a/seriestreewidget.h b/seriestreewidget.h
index 4532ddb..c5d91d4 100644
--- a/seriestreewidget.h
+++ b/seriestreewidget.h
@@ -22,9 +22,10 @@ class QLabel;
class SeriesTreeModel;
class SeriesTreeView;
class SeriesTreeSortModel;
-class SeriesTreeHoverWindow;
+class HoverWindow;
class FilesTreeModel;
class AddCoverDialog;
+class HoverWindow;
class SeriesTreeWidget : public QWidget {
Q_OBJECT
@@ -77,19 +78,9 @@ class SeriesTreeView : public QTreeView {
private:
QStringList children(const QModelIndex &idx) const;
QModelIndex mCurHover;
- SeriesTreeHoverWindow *mHoverWin;
- int mCursorOffset;
+ HoverWindow *mHoverWin;
};
-class SeriesTreeHoverWindow : public QWidget {
- Q_OBJECT
- public:
- explicit SeriesTreeHoverWindow(QWidget *parent = 0, Qt::WindowFlags f = Qt::FramelessWindowHint);
- void setContent(const QString &parent, const QStringList &children);
-
- private:
- QLabel *mLabel;
-};
class SeriesTreeSortModel : public QSortFilterProxyModel {
Q_OBJECT
diff --git a/shemov.pro b/shemov.pro
index dc3cc47..2015955 100644
--- a/shemov.pro
+++ b/shemov.pro
@@ -32,7 +32,8 @@ SOURCES = main.cpp \
mappingtablemodel.cpp \
mappingtablewidget.cpp \
newmoviewizard.cpp \
- filepropertiesdialog.cpp
+ filepropertiesdialog.cpp \
+ hoverwindow.cpp
HEADERS = listitem.h \
filesystemdirproxy.h \
filesystemwidget.h \
@@ -59,6 +60,7 @@ HEADERS = listitem.h \
mappingtablemodel.h \
mappingtablewidget.h \
newmoviewizard.h \
- filepropertiesdialog.h
+ filepropertiesdialog.h \
+ hoverwindow.h
LIBS += -lmagic -lXfixes
RESOURCES = shemov.qrc
diff --git a/smglobals.cpp b/smglobals.cpp
index e70da89..84f0fd8 100644
--- a/smglobals.cpp
+++ b/smglobals.cpp
@@ -11,6 +11,10 @@
#include <QMessageBox>
#include <QSettings>
+#include <QX11Info>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xfixes.h>
+
#include "smglobals.h"
#include "seriestreemodel.h"
#include "filestreemodel.h"
@@ -80,4 +84,13 @@ PictureViewer *SmGlobals::pictureViewer() {
return mPictureViewer;
}
-SmGlobals::SmGlobals() : mPictureViewer(0) {}
+int SmGlobals::cursorOffset() {
+ if(mCursorOffset == -1){
+ XFixesCursorImage *curImage = XFixesGetCursorImage(QX11Info::display());
+ mCursorOffset = curImage->height;
+ XFree(curImage);
+ }
+ return mCursorOffset;
+}
+
+SmGlobals::SmGlobals() : mPictureViewer(0), mCursorOffset(-1) {}
diff --git a/smglobals.h b/smglobals.h
index 50db16a..e1683ee 100644
--- a/smglobals.h
+++ b/smglobals.h
@@ -20,6 +20,7 @@ class SmGlobals : public QObject {
static SmGlobals *instance();
QAbstractItemModel *model(const QString &which);
PictureViewer *pictureViewer();
+ int cursorOffset();
private:
SmGlobals();
@@ -28,6 +29,7 @@ class SmGlobals : public QObject {
static SmGlobals *mInstance;
QHash<QString, QAbstractItemModel*> mModels;
PictureViewer *mPictureViewer;
+ int mCursorOffset;
};
#endif