summaryrefslogtreecommitdiffstats
path: root/scribus/shadebutton.cpp
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-01 11:40:09 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-01 11:40:09 +0000
commit7ed83b6c6666eb8b6b104c211ae7e52907350372 (patch)
tree4430b556abac0ad660a0aacf1887d77f85d8be02 /scribus/shadebutton.cpp
downloadscribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.gz
scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.xz
scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.zip
Branch 1.3.5 tree to 1.4.x tree, goodbye 1.3.x
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17163 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/shadebutton.cpp')
-rw-r--r--scribus/shadebutton.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/scribus/shadebutton.cpp b/scribus/shadebutton.cpp
new file mode 100644
index 0000000..dd84efa
--- /dev/null
+++ b/scribus/shadebutton.cpp
@@ -0,0 +1,89 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#include "shadebutton.h"
+#include "query.h"
+
+
+ShadeButton::ShadeButton(QWidget* parent) : QToolButton(parent)
+{
+ QString tmp[] = {"0 %", "10 %", "20 %", "30 %", "40 %", "50 %", "60 %", "70 %", "80 %", "90 %", "100 %"};
+ size_t array = sizeof(tmp) / sizeof(*tmp);
+ FillSh = new QMenu();
+ FillSh->addAction( tr("Other..."))->setCheckable(true);
+ for (uint a = 0; a < array; ++a)
+ FillSh->addAction(tmp[a])->setCheckable(true);
+ setMenu(FillSh);
+ setPopupMode(QToolButton::InstantPopup);
+ setText("100 %");
+ FillSh->actions()[11]->setChecked(true);
+ connect( FillSh, SIGNAL(triggered(QAction *)), this, SLOT(setShade(QAction *)));
+}
+
+void ShadeButton::setShade(QAction *act)
+{
+ bool ok = false;
+ int a;
+ int c;
+ int b = 100;
+ for (a = 0; a < FillSh->actions().count(); ++a)
+ {
+ FillSh->actions()[a]->setChecked(false);
+ }
+ act->setChecked(true);
+ QList<QAction*> actList = FillSh->actions();
+ c = actList.indexOf(act);
+ if (c < 0)
+ return;
+ if (c > 0)
+ b = (c-1) * 10;
+
+ if (b > 100)
+ return; // no need for > 100%, fix needed by SM, Riku
+
+ if (c == 0)
+ {
+ Query* dia = new Query(this, "New", 1, 0, tr("&Shade:"), tr("Shade"));
+ if (dia->exec())
+ {
+ c = dia->getEditText().toInt(&ok);
+ if (ok)
+ b = qMax(qMin(c, 100),0);
+ else
+ b = 100;
+ delete dia;
+ }
+ else
+ {
+ delete dia;
+ return;
+ }
+ }
+ setText(QString::number(b)+" %");
+ emit clicked();
+}
+
+int ShadeButton::getValue()
+{
+ int l = text().length();
+ QString tx = text().remove(l-2,2);
+ return tx.toInt();
+}
+
+void ShadeButton::setValue(int val)
+{
+ for (int a = 0; a < FillSh->actions().count(); ++a)
+ {
+ FillSh->actions()[a]->setChecked(false);
+ }
+ if ((val % 10) == 0)
+ FillSh->actions()[val/10+1]->setChecked(true);
+ else
+ FillSh->actions()[0]->setChecked(true);
+ setText(QString::number(val)+" %");
+}
+
+