aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2018-03-21 18:49:01 -0400
committerZackaryWelch <welch.zackary@gmail.com>2018-03-21 18:49:13 -0400
commit65e219e1dd55bbebc7c02feddfa2b770f4d80f3a (patch)
tree17c4159c88457ab3ec33ddf8a8c3966ff26ffb61 /src-qt5/desktop-utils/lumina-pdf/mainUI.cpp
parentUpdate the port makefile for deskutils/lumina-pdf to expose the MuPDF/Poppler... (diff)
downloadlumina-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/lumina-pdf/mainUI.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/mainUI.cpp47
1 files changed, 20 insertions, 27 deletions
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) );
+}
bgstack15