diff options
Diffstat (limited to 'stylepalette.cpp')
-rw-r--r-- | stylepalette.cpp | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/stylepalette.cpp b/stylepalette.cpp deleted file mode 100644 index c599750..0000000 --- a/stylepalette.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "stylepalette.h" -#include "ui_stylepalette.h" -#include "tikzit.h" - -#include <QDebug> -#include <QIcon> -#include <QSize> -#include <QSettings> -#include <QPainter> -#include <QPixmap> -#include <QPainterPath> - -StylePalette::StylePalette(QWidget *parent) : - QDockWidget(parent), - ui(new Ui::StylePalette) -{ - ui->setupUi(this); - -// QSettings settings("tikzit", "tikzit"); -// QVariant geom = settings.value("style-palette-geometry"); -// if (geom != QVariant()) { -// restoreGeometry(geom.toByteArray()); -// } - - _model = new QStandardItemModel(this); - ui->styleListView->setModel(_model); - ui->styleListView->setViewMode(QListView::IconMode); - ui->styleListView->setMovement(QListView::Static); - ui->styleListView->setGridSize(QSize(70,40)); - - reloadStyles(); - - connect(ui->styleListView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT( itemDoubleClicked(const QModelIndex&)) ); -} - -StylePalette::~StylePalette() -{ - delete ui; -} - -void StylePalette::reloadStyles() -{ - _model->clear(); - QString f = tikzit->styleFile(); - // - ui->styleFile->setText(f); - - QStandardItem *it; - //QSize sz(60,60); - - it = new QStandardItem(noneStyle->icon(), noneStyle->name()); - it->setEditable(false); - it->setData(noneStyle->name()); - _model->appendRow(it); - - foreach(NodeStyle *ns, tikzit->styles()->nodeStyles()) { - it = new QStandardItem(ns->icon(), ns->name()); - it->setEditable(false); - it->setData(ns->name()); - _model->appendRow(it); - } -} - -void StylePalette::changeStyle(int increment) -{ - QModelIndexList i = ui->styleListView->selectionModel()->selectedIndexes(); - int row = 0; - if (!i.isEmpty()) { - int row = (i[0].row()+increment)%_model->rowCount(); - if (row < 0) row += _model->rowCount(); - } - - QModelIndex i1 = ui->styleListView->rootIndex().child(row, 0); - ui->styleListView->selectionModel()->select(i1, QItemSelectionModel::ClearAndSelect); - ui->styleListView->scrollTo(i1); -} - -void StylePalette::nextStyle() -{ - changeStyle(1); -} - -void StylePalette::previousStyle() -{ - changeStyle(-1); -} - -QString StylePalette::activeNodeStyleName() -{ - const QModelIndexList i = ui->styleListView->selectionModel()->selectedIndexes(); - - if (i.isEmpty()) { - return "none"; - } else { - return i[0].data().toString(); - } -} - -void StylePalette::itemDoubleClicked(const QModelIndex &index) -{ - tikzit->activeWindow()->tikzScene()->applyActiveStyleToNodes(); -} - -void StylePalette::on_buttonOpenTikzstyles_clicked() -{ - tikzit->openTikzStyles(); -} - -void StylePalette::on_buttonRefreshTikzstyles_clicked() -{ - QSettings settings("tikzit", "tikzit"); - QString path = settings.value("previous-tikzstyles-file").toString(); - if (!path.isEmpty()) tikzit->loadStyles(path); -} - -//void StylePalette::on_buttonApplyNodeStyle_clicked() -//{ -// if (tikzit->activeWindow() != 0) tikzit->activeWindow()->tikzScene()->applyActiveStyleToNodes(); -//} - -void StylePalette::closeEvent(QCloseEvent *event) -{ - QSettings settings("tikzit", "tikzit"); - settings.setValue("style-palette-geometry", saveGeometry()); - QDockWidget::closeEvent(event); -} |