diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2018-03-21 18:49:01 -0400 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2018-03-21 18:49:13 -0400 |
commit | 65e219e1dd55bbebc7c02feddfa2b770f4d80f3a (patch) | |
tree | 17c4159c88457ab3ec33ddf8a8c3966ff26ffb61 /src-qt5/desktop-utils | |
parent | Update the port makefile for deskutils/lumina-pdf to expose the MuPDF/Poppler... (diff) | |
download | lumina-65e219e1dd55bbebc7c02feddfa2b770f4d80f3a.tar.gz lumina-65e219e1dd55bbebc7c02feddfa2b770f4d80f3a.tar.bz2 lumina-65e219e1dd55bbebc7c02feddfa2b770f4d80f3a.zip |
Added a splitter for the bookmarks menu to be able to change size
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp | 5 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp | 19 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 47 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.ui | 47 |
5 files changed, 47 insertions, 72 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp index 39d4e314..a90007d8 100644 --- a/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/BookmarkMenu.cpp @@ -8,10 +8,13 @@ #include "BookmarkMenu.h" #include "ui_BookmarkMenu.h" #include <LuminaXDG.h> +#include <QSplitter> +#include <QPushButton> BookmarkMenu::BookmarkMenu(Renderer *Backend, QWidget *parent) : QWidget(parent), ui(new Ui::BookmarkMenu()), BACKEND(Backend){ ui->setupUi(this); - connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close())); + connect(ui->closeButton, &QPushButton::clicked, parent, [=]() { static_cast<QSplitter*>(parent)->setSizes(QList<int>() << 0 << this->width()); }); + connect(ui->closeButton, &QPushButton::clicked, parent, [=]() { }); connect(ui->bookmarks, &QTreeWidget::itemClicked, this, [=](QTreeWidgetItem *item) { Backend->handleLink(item->data(1, Qt::UserRole).toString()); }); } diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp index 65a71a74..2ef271de 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp @@ -156,6 +156,7 @@ void PrintWidget::highlightText(TextData *text) { QPen highlightOutline(QColor(255, 255, 100, 125)); scene->addRect(rect, highlightOutline, highlightFill); text->highlighted(true); + goToPosition(text->page(), rect.x(), rect.y()); } } @@ -316,16 +317,12 @@ void PrintWidget::fit(bool doFitting) { void PrintWidget::goToPosition(int pagenum, float x, float y) { setCurrentPage(pagenum+1); - QPointF pt = this->transform().map(pages.at(pagenum)->pos()); - - if (zoomMode != FitInView) { - if(x != 0) { - QScrollBar *hsc = this->horizontalScrollBar(); - hsc->setValue(int(pt.x() + x) - 10); - } - if(y != 0) { - QScrollBar *vsc = this->verticalScrollBar(); - vsc->setValue(int(pt.y() + y) - 10); - } + if(x != 0) { + QScrollBar *hsc = this->horizontalScrollBar(); + hsc->setValue((int)x - 10); + } + if(y != 0) { + QScrollBar *vsc = this->verticalScrollBar(); + vsc->setValue((int)y - 10); } } diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index b25f61fb..24955bb1 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -15,8 +15,8 @@ #include <QDebug> #include <QApplication> #include <QScreen> -#include <iostream> #include <QtConcurrent> +#include <QSplitter> #include <LuminaXDG.h> #include "PrintWidget.h" @@ -29,44 +29,35 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ CurrentPage = 1; lastdir = QDir::homePath(); BACKEND = new Renderer(); + + //Create the interface widgets PROPDIALOG = new PropDialog(BACKEND); - BOOKMARKS = new BookmarkMenu(BACKEND, this->centralWidget()); + BOOKMARKS = new BookmarkMenu(BACKEND, ui->splitter); BOOKMARKS->setContextMenuPolicy(Qt::CustomContextMenu); - //BOOKMARKS->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - //Create the interface widgets - WIDGET = new PrintWidget(BACKEND, this->centralWidget()); + WIDGET = new PrintWidget(BACKEND, ui->splitter); WIDGET->setContextMenuPolicy(Qt::CustomContextMenu); - //WIDGET->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - loadingQueue.clear(); + ui->splitter->setCollapsible(0, true); + ui->splitter->setCollapsible(1, false); clockTimer = new QTimer(this); clockTimer->setInterval(1000); //1-second updates to clock connect(clockTimer, SIGNAL(timeout()), this, SLOT(updateClock()) ); - //frame_presenter = new QFrame(this); label_clock = new QLabel(this); label_clock->setAlignment(Qt::AlignCenter ); label_clock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); label_clock->setStyleSheet("QLabel{color: palette(highlight-text); background-color: palette(highlight); border-radius: 5px; }"); - label_page = new QLabel(this); label_page->setAlignment(Qt::AlignRight | Qt::AlignVCenter); label_page->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - //Context Menu + contextMenu = new QMenu(this); connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); - this->centralWidget()->layout()->replaceWidget(ui->label_replaceme, WIDGET); - ui->label_replaceme->setVisible(false); - this->centralWidget()->layout()->replaceWidget(ui->label_replaceme2, BOOKMARKS); - ui->label_replaceme2->setVisible(false); - QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); - policy.setHorizontalStretch(1); - BOOKMARKS->setSizePolicy(policy); - policy.setHorizontalStretch(4); - WIDGET->setSizePolicy(policy); + connect(WIDGET, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(showContextMenu(const QPoint&)) ); connect(WIDGET, SIGNAL(currentPageChanged()), this, SLOT(updatePageNumber()) ); connect(BACKEND, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) ); connect(BACKEND, SIGNAL(reloadPages(int)), this, SLOT(startLoadingPages(int))); connect(BACKEND, SIGNAL(goToPosition(int, float, float)), WIDGET, SLOT(goToPosition(int, float, float))); + connect(ui->splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(splitterMoved()) ); PrintDLG = new QPrintDialog(this); connect(PrintDLG, SIGNAL(accepted(QPrinter*)), this, SLOT(paintToPrinter(QPrinter*)) ); @@ -97,8 +88,6 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ tmp->addAction(ui->actionAll_Pages); ui->actionSingle_Page->setChecked(true); - //qDebug() << "Starting connections"; - //Connect up the buttons connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) ); connect(ui->actionPrint, SIGNAL(triggered()), PrintDLG, SLOT(open()) ); @@ -145,9 +134,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ [&] { ui->findGroup->setVisible(false); this->setFocus(); }); connect(ui->actionClearHighlights, &QAction::triggered, WIDGET, [&] { WIDGET->updatePreview(); }); - connect(ui->actionBookmarks, &QAction::triggered, this, [=] () { BOOKMARKS->setVisible(true); }); - - //qDebug() << "Finished connctions"; + connect(ui->actionBookmarks, &QAction::triggered, this, [=] () { ui->splitter->setSizes( QList<int>() << this->width()/4 << 3*this->width()/4); }); //int curP = WIDGET->currentPage()-1; //currentPage reports pages starting at 1 //int lastP = numPages-1; @@ -371,6 +358,7 @@ void MainUI::startLoadingPages(int degrees){ loadingQueue.clear(); BACKEND->clearHash(); WIDGET->setVisible(false); + BOOKMARKS->setVisible(false); //qDebug() << "Update Progress Bar"; progress->setRange(0, BACKEND->numPages()); progress->setValue(0); @@ -408,6 +396,8 @@ void MainUI::slotPageLoaded(int page){ if(finished == BACKEND->numPages()){ progAct->setVisible(false); WIDGET->setVisible(true); + BOOKMARKS->setVisible(true); + ui->splitter->setSizes(QList<int>() << 0 << this->width()); WIDGET->setCurrentPage(1); ui->actionStop_Presentation->setEnabled(false); ui->actionStart_Here->setEnabled(true); @@ -628,9 +618,6 @@ void MainUI::find(QString text, bool forward) { ui->resultsLabel->setText(QString::number(currentHighlight+1) + " of " + QString::number(results.size()) + " results"); TextData *currentText = results[currentHighlight]; - WIDGET->setCurrentPage(currentText->page()); - - //qDebug() << "Jump to page: " << currentText.page; if(BACKEND->supportsExtraFeatures()) WIDGET->highlightText(currentText); @@ -639,3 +626,9 @@ void MainUI::find(QString text, bool forward) { } } } + +void MainUI::splitterMoved() { + float percent = (ui->splitter->sizes().first() / ( (float) this->width()) )*100.0; + percent = percent > 33.3 ? 33.3 : percent; + ui->splitter->setSizes( QList<int>() << this->width()*(percent/100.0) << this->width() * ((100.0-percent)/100.0) ); +} diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h index 10f2d2e4..e8760c55 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h @@ -98,6 +98,7 @@ private slots: void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); } void updateContextMenu(); //void setScroll(bool); + void splitterMoved(); protected: void keyPressEvent(QKeyEvent*); diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui index 09a5862d..ec35345b 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui @@ -15,39 +15,7 @@ </property> <widget class="QWidget" name="centralwidget"> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_replaceme2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Bookmarks Area</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_replaceme"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>3</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string notr="true">GraphicsArea (replaced)</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> + <item row="1" column="0"> <widget class="QFrame" name="findGroup"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> @@ -127,6 +95,19 @@ </layout> </widget> </item> + <item row="0" column="0"> + <widget class="QSplitter" name="splitter"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> |