FreeCAD

Форк
0
/
TaskPanelView.cpp 
641 строка · 25.8 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2009 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23

24
#include "PreCompiled.h"
25

26
/// Here the FreeCAD includes sorted by Base,App,Gui......
27

28
#include <boost/bind/bind.hpp>
29
#include <QVariant>
30
#include <QAction>
31
#include <QApplication>
32
#include <QButtonGroup>
33
#include <QFrame>
34
#include <QGridLayout>
35
#include <QHeaderView>
36
#include <QLabel>
37
#include <QSpacerItem>
38
#include <QVBoxLayout>
39
#include <QWidget>
40
#include <QTabWidget>
41

42
#include <QButtonGroup>
43
#include <QPushButton>
44
#include <QCheckBox>
45
#include <QRadioButton>
46
#include <QMessageBox>
47

48
#include <Gui/ActionFunction.h>
49
#include <Gui/Application.h>
50
#include <Gui/Command.h>
51
#include <Gui/TaskView/TaskView.h>
52
#include <Gui/BitmapFactory.h>
53

54
#include "TaskPanelView.h"
55

56

57
using namespace SandboxGui;
58
namespace bp = boost::placeholders;
59

60

61
#if defined(QSINT_ACTIONPANEL)
62
class Ui_TaskGroup
63
{
64
public:
65
    QAction *actionNew;
66
    QAction *actionLoad;
67
    QAction *actionSave;
68
    QAction *actionPrint;
69
    QGridLayout *gridLayout;
70
    QSint::ActionPanel *ActionPanel;
71
    QSint::ActionGroup *ActionGroup1;
72
    QVBoxLayout *verticalLayout;
73
    QRadioButton *rbDefaultScheme;
74
    QRadioButton *rbXPBlueScheme;
75
    QRadioButton *rbXPBlue2Scheme;
76
    QRadioButton *rbVistaScheme;
77
    QRadioButton *rbMacScheme;
78
    QRadioButton *rbAndroidScheme;
79
    QSpacerItem *verticalSpacer;
80

81
    void setupUi(QWidget *MainWindow2)
82
    {
83
        if (MainWindow2->objectName().isEmpty())
84
            MainWindow2->setObjectName(QString::fromUtf8("MainWindow2"));
85
        MainWindow2->resize(529, 407);
86
        MainWindow2->setStyleSheet(QString::fromUtf8("\n"
87
            "QWidget2 {\n"
88
"    background-color: green;\n"
89
"}\n"
90
""));
91
        actionNew = new QAction(MainWindow2);
92
        actionNew->setObjectName(QString::fromUtf8("actionNew"));
93
        QIcon icon;
94
        icon.addFile(QString::fromUtf8(":/icons/document-new.svg"), QSize(), QIcon::Normal, QIcon::Off);
95
        actionNew->setIcon(icon);
96
        actionLoad = new QAction(MainWindow2);
97
        actionLoad->setObjectName(QString::fromUtf8("actionLoad"));
98
        QIcon icon1;
99
        icon1.addFile(QString::fromUtf8(":/icons/document-open.svg"), QSize(), QIcon::Normal, QIcon::Off);
100
        actionLoad->setIcon(icon1);
101
        actionSave = new QAction(MainWindow2);
102
        actionSave->setObjectName(QString::fromUtf8("actionSave"));
103
        actionSave->setEnabled(false);
104
        QIcon icon2;
105
        icon2.addFile(QString::fromUtf8(":/icons/document-save.svg"), QSize(), QIcon::Normal, QIcon::Off);
106
        actionSave->setIcon(icon2);
107
        actionPrint = new QAction(MainWindow2);
108
        actionPrint->setObjectName(QString::fromUtf8("actionPrint"));
109
        QIcon icon3;
110
        icon3.addFile(QString::fromUtf8(":/icons/document-print.svg"), QSize(), QIcon::Normal, QIcon::Off);
111
        actionPrint->setIcon(icon3);
112
        gridLayout = new QGridLayout(MainWindow2);
113
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
114
        ActionPanel = new QSint::ActionPanel(MainWindow2);
115
        ActionPanel->setObjectName(QString::fromUtf8("ActionPanel"));
116
        QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
117
        sizePolicy.setHorizontalStretch(0);
118
        sizePolicy.setVerticalStretch(0);
119
        sizePolicy.setHeightForWidth(ActionPanel->sizePolicy().hasHeightForWidth());
120
        ActionPanel->setSizePolicy(sizePolicy);
121

122
        gridLayout->addWidget(ActionPanel, 0, 0, 2, 1);
123

124
        ActionGroup1 = new QSint::ActionGroup(MainWindow2);
125
        ActionGroup1->setObjectName(QString::fromUtf8("ActionGroup1"));
126
        ActionGroup1->setProperty("expandable", QVariant(true));
127
        ActionGroup1->setProperty("header", QVariant(true));
128
        verticalLayout = new QVBoxLayout(ActionGroup1);
129
        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
130
        rbDefaultScheme = new QRadioButton(ActionGroup1);
131
        rbDefaultScheme->setObjectName(QString::fromUtf8("rbDefaultScheme"));
132
        rbDefaultScheme->setChecked(true);
133

134
        verticalLayout->addWidget(rbDefaultScheme);
135

136
        rbXPBlueScheme = new QRadioButton(ActionGroup1);
137
        rbXPBlueScheme->setObjectName(QString::fromUtf8("rbXPBlueScheme"));
138

139
        verticalLayout->addWidget(rbXPBlueScheme);
140

141
        rbXPBlue2Scheme = new QRadioButton(ActionGroup1);
142
        rbXPBlue2Scheme->setObjectName(QString::fromUtf8("rbXPBlue2Scheme"));
143

144
        verticalLayout->addWidget(rbXPBlue2Scheme);
145

146
        rbVistaScheme = new QRadioButton(ActionGroup1);
147
        rbVistaScheme->setObjectName(QString::fromUtf8("rbVistaScheme"));
148

149
        verticalLayout->addWidget(rbVistaScheme);
150

151
        rbMacScheme = new QRadioButton(ActionGroup1);
152
        rbMacScheme->setObjectName(QString::fromUtf8("rbMacScheme"));
153

154
        verticalLayout->addWidget(rbMacScheme);
155

156
        rbAndroidScheme = new QRadioButton(ActionGroup1);
157
        rbAndroidScheme->setObjectName(QString::fromUtf8("rbAndroidScheme"));
158

159
        verticalLayout->addWidget(rbAndroidScheme);
160

161

162
        gridLayout->addWidget(ActionGroup1, 0, 1, 1, 1);
163

164
        verticalSpacer = new QSpacerItem(20, 57, QSizePolicy::Minimum, QSizePolicy::Expanding);
165

166
        gridLayout->addItem(verticalSpacer, 1, 1, 1, 1);
167

168

169
        retranslateUi(MainWindow2);
170

171
        QMetaObject::connectSlotsByName(MainWindow2);
172
    } // setupUi
173

174
    void retranslateUi(QWidget *MainWindow2)
175
    {
176
        MainWindow2->setWindowTitle(QApplication::translate("MainWindow2", "ActionBox Example"));
177
        actionNew->setText(QApplication::translate("MainWindow2", "Create new file"));
178
        actionLoad->setText(QApplication::translate("MainWindow2", "Load a file"));
179
        actionSave->setText(QApplication::translate("MainWindow2", "Save current file"));
180
        actionPrint->setText(QApplication::translate("MainWindow2", "Print file contents"));
181
        ActionGroup1->setProperty("headerText", QVariant(QApplication::translate("MainWindow2", "Choose Scheme")));
182
        rbDefaultScheme->setText(QApplication::translate("MainWindow2", "Default"));
183
        rbXPBlueScheme->setText(QApplication::translate("MainWindow2", "XP Blue"));
184
        rbXPBlue2Scheme->setText(QApplication::translate("MainWindow2", "XP Blue 2"));
185
        rbVistaScheme->setText(QApplication::translate("MainWindow2", "Vista"));
186
        rbMacScheme->setText(QApplication::translate("MainWindow2", "MacOS"));
187
        rbAndroidScheme->setText(QApplication::translate("MainWindow2", "Android"));
188
        Q_UNUSED(MainWindow2);
189
    } // retranslateUi
190

191
};
192

193
class Ui_TaskActionBox
194
{
195
public:
196
    QVBoxLayout *verticalLayout;
197
    QVBoxLayout *verticalLayout_3;
198
    QLabel *label;
199
    QFrame *line_2;
200
    QGridLayout *gridLayout_2;
201
    QSint::ActionBox *ActionBox1;
202
    QSint::ActionBox *ActionBox2;
203
    QSpacerItem *verticalSpacer;
204
    QSint::ActionBox *ActionBox3;
205
    QSint::ActionBox *ActionBox4;
206
    Gui::TaskView::TaskGroup *ActionBox5;
207
    QVBoxLayout *verticalLayout_4;
208
    QLabel *label_2;
209
    QFrame *line;
210
    QVBoxLayout *verticalLayout_2;
211
    QSint::ActionLabel *ActionLabel1;
212
    QSint::ActionLabel *ActionLabel2;
213
    QSint::ActionLabel *ActionLabel3;
214

215
    void setupUi(QWidget *MainWindow)
216
    {
217
        MainWindow->resize(642, 850);
218
        QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
219
        sizePolicy.setHorizontalStretch(0);
220
        sizePolicy.setVerticalStretch(0);
221
        sizePolicy.setHeightForWidth(MainWindow->sizePolicy().hasHeightForWidth());
222
        MainWindow->setSizePolicy(sizePolicy);
223
        MainWindow->setStyleSheet(QString::fromUtf8("\n"
224
"SandboxGui--TaskPanelView {\n"
225
"	background-color: green;\n"
226
"}\n"
227
""));
228
        verticalLayout = new QVBoxLayout(MainWindow);
229
        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
230
        verticalLayout_3 = new QVBoxLayout();
231
        verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
232
        label = new QLabel(MainWindow);
233
        label->setObjectName(QString::fromUtf8("label"));
234
        QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Maximum);
235
        sizePolicy1.setHorizontalStretch(0);
236
        sizePolicy1.setVerticalStretch(0);
237
        sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
238
        label->setSizePolicy(sizePolicy1);
239

240
        verticalLayout_3->addWidget(label);
241

242
        line_2 = new QFrame(MainWindow);
243
        line_2->setObjectName(QString::fromUtf8("line_2"));
244
        line_2->setFrameShape(QFrame::HLine);
245
        line_2->setFrameShadow(QFrame::Sunken);
246

247
        verticalLayout_3->addWidget(line_2);
248

249

250
        verticalLayout->addLayout(verticalLayout_3);
251

252
        gridLayout_2 = new QGridLayout();
253
        gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
254
        ActionBox1 = new QSint::ActionBox(MainWindow);
255
        ActionBox1->setObjectName(QString::fromUtf8("ActionBox1"));
256
        ActionBox1->setFrameShape(QFrame::StyledPanel);
257
        ActionBox1->setFrameShadow(QFrame::Raised);
258

259
        gridLayout_2->addWidget(ActionBox1, 0, 0, 1, 1);
260

261
        ActionBox2 = new QSint::ActionBox(MainWindow);
262
        ActionBox2->setObjectName(QString::fromUtf8("ActionBox2"));
263
        ActionBox2->setFrameShape(QFrame::StyledPanel);
264
        ActionBox2->setFrameShadow(QFrame::Raised);
265

266
        gridLayout_2->addWidget(ActionBox2, 1, 0, 1, 1);
267

268
        verticalSpacer = new QSpacerItem(94, 28, QSizePolicy::Minimum, QSizePolicy::Minimum);
269

270
        gridLayout_2->addItem(verticalSpacer, 3, 0, 1, 1);
271

272
        ActionBox3 = new QSint::ActionBox(MainWindow);
273
        ActionBox3->setObjectName(QString::fromUtf8("ActionBox3"));
274
        ActionBox3->setFrameShape(QFrame::StyledPanel);
275
        ActionBox3->setFrameShadow(QFrame::Raised);
276

277
        gridLayout_2->addWidget(ActionBox3, 0, 1, 1, 1);
278

279
        ActionBox4 = new QSint::ActionBox(MainWindow);
280
        ActionBox4->setObjectName(QString::fromUtf8("ActionBox4"));
281
        ActionBox4->setFrameShape(QFrame::StyledPanel);
282
        ActionBox4->setFrameShadow(QFrame::Raised);
283

284
        gridLayout_2->addWidget(ActionBox4, 1, 1, 1, 1);
285

286
        ActionBox5 = new Gui::TaskView::TaskGroup(MainWindow);
287
        ActionBox5->setObjectName(QString::fromUtf8("ActionBox5"));
288
        ActionBox5->setFrameShape(QFrame::StyledPanel);
289
        ActionBox5->setFrameShadow(QFrame::Raised);
290

291
        gridLayout_2->addWidget(ActionBox5, 2, 1, 1, 1);
292

293
        verticalLayout->addLayout(gridLayout_2);
294

295
        verticalLayout_4 = new QVBoxLayout();
296
        verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
297
        label_2 = new QLabel(MainWindow);
298
        label_2->setObjectName(QString::fromUtf8("label_2"));
299
        sizePolicy1.setHeightForWidth(label_2->sizePolicy().hasHeightForWidth());
300
        label_2->setSizePolicy(sizePolicy1);
301

302
        verticalLayout_4->addWidget(label_2);
303

304
        line = new QFrame(MainWindow);
305
        line->setObjectName(QString::fromUtf8("line"));
306
        line->setFrameShape(QFrame::HLine);
307
        line->setFrameShadow(QFrame::Sunken);
308

309
        verticalLayout_4->addWidget(line);
310

311

312
        verticalLayout->addLayout(verticalLayout_4);
313

314
        verticalLayout_2 = new QVBoxLayout();
315
        verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
316
        ActionLabel1 = new QSint::ActionLabel(MainWindow);
317
        ActionLabel1->setObjectName(QString::fromUtf8("ActionLabel1"));
318
        QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Fixed);
319
        sizePolicy2.setHorizontalStretch(0);
320
        sizePolicy2.setVerticalStretch(0);
321
        sizePolicy2.setHeightForWidth(ActionLabel1->sizePolicy().hasHeightForWidth());
322
        ActionLabel1->setSizePolicy(sizePolicy2);
323

324
        verticalLayout_2->addWidget(ActionLabel1);
325

326
        ActionLabel2 = new QSint::ActionLabel(MainWindow);
327
        ActionLabel2->setObjectName(QString::fromUtf8("ActionLabel2"));
328
        sizePolicy2.setHeightForWidth(ActionLabel2->sizePolicy().hasHeightForWidth());
329
        ActionLabel2->setSizePolicy(sizePolicy2);
330
        QIcon icon;
331
        icon.addFile(QString::fromUtf8(":/icons/document-open.svg"), QSize(), QIcon::Normal, QIcon::Off);
332
        ActionLabel2->setIcon(icon);
333

334
        verticalLayout_2->addWidget(ActionLabel2);
335

336
        ActionLabel3 = new QSint::ActionLabel(MainWindow);
337
        ActionLabel3->setObjectName(QString::fromUtf8("ActionLabel3"));
338
        sizePolicy2.setHeightForWidth(ActionLabel3->sizePolicy().hasHeightForWidth());
339
        ActionLabel3->setSizePolicy(sizePolicy2);
340
        QIcon icon1;
341
        icon1.addFile(QString::fromUtf8(":/icons/document-print.svg"), QSize(), QIcon::Normal, QIcon::Off);
342
        ActionLabel3->setIcon(icon1);
343

344
        verticalLayout_2->addWidget(ActionLabel3);
345

346

347
        verticalLayout->addLayout(verticalLayout_2);
348

349

350
        retranslateUi(MainWindow);
351
    } // setupUi
352

353
    void retranslateUi(QWidget *MainWindow)
354
    {
355
        MainWindow->setWindowTitle(QApplication::translate("TestTaskBox", "ActionBox Example"));
356
        label->setText(QApplication::translate("TestTaskBox", "ActionBoxes"));
357
        label_2->setText(QApplication::translate("TestTaskBox", "ActionLabels"));
358
        ActionLabel1->setText(QApplication::translate("TestTaskBox", "Simple clickable action"));
359
        ActionLabel2->setText(QApplication::translate("TestTaskBox", "Simple clickable action with icon"));
360
#ifndef QT_NO_TOOLTIP
361
        ActionLabel3->setToolTip(QApplication::translate("TestTaskBox", "Tooltip of the ActionLabel"));
362
#endif // QT_NO_TOOLTIP
363
        ActionLabel3->setText(QApplication::translate("TestTaskBox", "Simple clickable action with icon and tooltip"));
364
        Q_UNUSED(MainWindow);
365
    } // retranslateUi
366
};
367
#endif
368

369
TaskPanelView::TaskPanelView(QWidget *parent)
370
  : QWidget(parent)
371
{
372
    Gui::ActionFunction* func = new Gui::ActionFunction(this);
373
    QAction* action = new QAction(this);
374
    func->trigger(action, boost::bind(&TaskPanelView::executeAction, this));
375

376
#if defined(QSINT_ACTIONPANEL)
377

378
    QGridLayout* customLayout = new QGridLayout(this);
379
    QTabWidget* tabWidget = new QTabWidget(this);
380
    customLayout->addWidget(tabWidget, 0, 0);
381
    this->resize(642, 850);
382

383
    {
384
    Ui_TaskActionBox* ui(new Ui_TaskActionBox);
385
    QWidget* page1 = new QWidget();
386
    ui->setupUi(page1);
387
    tabWidget->addTab(page1, QLatin1String("Action Box"));
388

389
    // setup ActionBox 1
390
    ui->ActionBox1->setIcon(QPixmap(QString::fromLatin1(":/icons/document-open.svg")));
391
    ui->ActionBox1->header()->setText(QString::fromLatin1("Header of the group"));
392
    connect(ui->ActionBox1->header(), SIGNAL(clicked()), action, SIGNAL(triggered()));
393

394
    QSint::ActionLabel *a1 = ui->ActionBox1->createItem(QString::fromLatin1("This action has no icon"));
395
    connect(a1, SIGNAL(clicked()), action, SIGNAL(triggered()));
396
    QSint::ActionLabel *a2 = ui->ActionBox1->createItem(QPixmap(QString::fromLatin1(":/icons/document-print.svg")),
397
                                                QString::fromLatin1("This action has icon"));
398
    connect(a2, SIGNAL(clicked()), action, SIGNAL(triggered()));
399

400
    QLayout *hbl1 = ui->ActionBox1->createHBoxLayout();
401
    QSint::ActionLabel *a3 = ui->ActionBox1->createItem(QString::fromLatin1("1st action in row"), hbl1);
402
    connect(a3, SIGNAL(clicked()), action, SIGNAL(triggered()));
403
    QSint::ActionLabel *a4 = ui->ActionBox1->createItem(QString::fromLatin1("2nd action in row"), hbl1);
404
    connect(a4, SIGNAL(clicked()), action, SIGNAL(triggered()));
405

406
    // setup ActionBox 2
407
    ui->ActionBox2->setIcon(QPixmap(QString::fromLatin1(":/icons/document-save.png")));
408
    ui->ActionBox2->header()->setText(QString::fromLatin1("Checkable actions allowed"));
409
    connect(ui->ActionBox2->header(), SIGNAL(clicked()), action, SIGNAL(triggered()));
410

411
    QSint::ActionLabel *b1 = ui->ActionBox2->createItem(QString::fromLatin1("Action 1 (Exclusive)"));
412
    b1->setCheckable(true);
413
    b1->setAutoExclusive(true);
414
    b1->setChecked(true);
415
    QSint::ActionLabel *b2 = ui->ActionBox2->createItem(QString::fromLatin1("Action 2 (Exclusive)"));
416
    b2->setCheckable(true);
417
    b2->setAutoExclusive(true);
418
    QSint::ActionLabel *b3 = ui->ActionBox2->createItem(QString::fromLatin1("Action 3 (Exclusive)"));
419
    b3->setCheckable(true);
420
    b3->setAutoExclusive(true);
421

422
    QSint::ActionLabel *b4 = ui->ActionBox2->createItem(QString::fromLatin1("Non-exclusive but still checkable"));
423
    b4->setCheckable(true);
424

425
    // setup ActionBox 3
426
    ui->ActionBox3->setIcon(QPixmap(QString::fromLatin1(":/icons/document-print.png")));
427
    ui->ActionBox3->header()->setText(QString::fromLatin1("Also, widgets allowed as well"));
428

429
    ui->ActionBox3->addWidget(new QPushButton(QString::fromLatin1("PushButton"), this));
430
    ui->ActionBox3->addWidget(new QCheckBox(QString::fromLatin1("CheckBox"), this));
431
    QLayout *hbl3 = ui->ActionBox3->createHBoxLayout();
432
    ui->ActionBox3->addWidget(new QRadioButton(QString::fromLatin1("RadioButton 1"), this), hbl3);
433
    ui->ActionBox3->addWidget(new QRadioButton(QString::fromLatin1("RadioButton 2"), this), hbl3);
434

435
    // setup ActionBox 4
436
    ui->ActionBox4->setIcon(QPixmap(QString::fromLatin1(":/icons/document-open.png")));
437
    ui->ActionBox4->header()->setText(QString::fromLatin1("ActionBox with different scheme"));
438

439
    ui->ActionBox4->createItem(QString::fromLatin1("This action has no icon"));
440
    ui->ActionBox4->createItem(QPixmap(QString::fromLatin1(":/icons/document-print.png")),
441
                                                QString::fromLatin1("This action has icon"));
442
    QLayout *hbl4 = ui->ActionBox4->createHBoxLayout();
443
    ui->ActionBox4->createItem(QString::fromLatin1("1st action in row"), hbl4);
444
    ui->ActionBox4->createItem(QString::fromLatin1("2nd action in row"), hbl4);
445
    ui->ActionBox4->createItem(QString::fromLatin1("3rd action in row"), hbl4);
446

447
    const char* ActionBoxNewStyle =
448
        "QSint--ActionBox {"
449
            "background-color: #333333;"
450
            "border: 1px solid #000000;"
451
            "text-align: left;"
452
        "}"
453

454
        "QSint--ActionBox:hover {"
455
            "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #666666, stop: 1 #333333);"
456
            "border: 1px solid #222222;"
457
        "}"
458

459
        "QSint--ActionBox QSint--ActionLabel[class='header'] {"
460
            "text-align: center;"
461
            "font: 14px bold;"
462
            "color: #999999;"
463
            "background-color: transparent;"
464
            "border: 1px solid transparent;"
465
        "}"
466

467
        "QSint--ActionBox QSint--ActionLabel[class='header']:hover {"
468
            "color: #aaaaaa;"
469
            "text-decoration: underline;"
470
            "border: 1px dotted #aaaaaa;"
471
        "}"
472

473
        "QSint--ActionBox QSint--ActionLabel[class='action'] {"
474
            "background-color: transparent;"
475
            "border: none;"
476
            "color: #777777;"
477
            "text-align: left;"
478
            "font: 11px;"
479
        "}"
480

481
        "QSint--ActionBox QSint--ActionLabel[class='action']:hover {"
482
            "color: #888888;"
483
            "text-decoration: underline;"
484
        "}"
485

486
        "QSint--ActionBox QSint--ActionLabel[class='action']:on {"
487
            "background-color: #ddeeff;"
488
            "color: #006600;"
489
        "}"
490
    ;
491

492
    ui->ActionBox4->setStyleSheet(QString::fromLatin1(ActionBoxNewStyle));
493

494
    // setup ActionBox 5
495
    Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
496
    ui->ActionBox5->setIcon(QPixmap(QString::fromLatin1(":/icons/document-save.png")));
497
    ui->ActionBox5->header()->setText(QString::fromLatin1("TaskGroup with different scheme"));
498

499
    rcCmdMgr.addTo("Std_New", ui->ActionBox5);
500
    rcCmdMgr.addTo("Std_Open", ui->ActionBox5);
501
    rcCmdMgr.addTo("Std_Save", ui->ActionBox5);
502
    ui->ActionBox5->setStyleSheet(QString::fromLatin1(ActionBoxNewStyle));
503
    }
504
    {
505
    Ui_TaskGroup* ui(new Ui_TaskGroup);
506
    QWidget* page2 = new QWidget();
507
    ui->setupUi(page2);
508
    tabWidget->addTab(page2, QLatin1String("Action Group"));
509

510
    this->actionGroup = ui->ActionPanel;
511

512
    // create ActionGroups on ActionPanel
513
    QIcon save = QIcon::fromTheme(QString::fromLatin1("document-save"));
514
    QSint::ActionGroup *group1 = ui->ActionPanel->createGroup(save.pixmap(24,24), QString::fromLatin1("Expandable Group"));
515
    group1->addAction(ui->actionNew);
516
    group1->addAction(ui->actionLoad);
517
    group1->addWidget(new QPushButton(QString::fromLatin1("Just a button"), this));
518
    group1->addAction(ui->actionSave);
519
    group1->addAction(ui->actionPrint);
520
    group1->addWidget(new QPushButton(QString::fromLatin1("Just another button"), this));
521

522
    QIcon redo = QIcon::fromTheme(QString::fromLatin1("edit-redo"));
523
    QSint::ActionGroup *group2 = ui->ActionPanel->createGroup(redo.pixmap(24,24), QString::fromLatin1("Non-Expandable Group"), false);
524
    group2->addAction(ui->actionNew);
525
    group2->addAction(ui->actionLoad);
526
    group2->addAction(ui->actionSave);
527
    group2->addAction(ui->actionPrint);
528

529
    ui->ActionPanel->addWidget(new QLabel(QString::fromLatin1("Action Group without header"), this));
530

531
    QSint::ActionGroup *group3 = ui->ActionPanel->createGroup();
532
    group3->addAction(ui->actionNew);
533

534
    QHBoxLayout *hbl = new QHBoxLayout();
535
    group3->groupLayout()->addLayout(hbl);
536
    hbl->addWidget(group3->addAction(ui->actionLoad, false));
537
    hbl->addWidget(group3->addAction(ui->actionSave, false));
538

539
    group3->addAction(ui->actionPrint);
540

541
    ui->ActionPanel->addStretch();
542

543

544
    // setup standalone ActionGroup
545

546
    ui->ActionGroup1->setScheme(QSint::WinXPPanelScheme::defaultScheme());
547

548
    ui->ActionGroup1->addWidget(ui->rbDefaultScheme);
549
    ui->ActionGroup1->addWidget(ui->rbXPBlueScheme);
550
    ui->ActionGroup1->addWidget(ui->rbXPBlue2Scheme);
551
    ui->ActionGroup1->addWidget(ui->rbVistaScheme);
552
    ui->ActionGroup1->addWidget(ui->rbMacScheme);
553
    ui->ActionGroup1->addWidget(ui->rbAndroidScheme);
554

555
    Gui::ActionFunction* func = new Gui::ActionFunction(this);
556

557
    QAction* defaultAction = new QAction(this);
558
    connect(ui->rbDefaultScheme, SIGNAL(toggled(bool)), defaultAction, SIGNAL(toggled(bool)));
559
    func->toggle(defaultAction, boost::bind(&TaskPanelView::on_rbDefaultScheme_toggled, this, bp::_1));
560

561
    QAction* xpBlueAction = new QAction(this);
562
    connect(ui->rbXPBlueScheme, SIGNAL(toggled(bool)), xpBlueAction, SIGNAL(toggled(bool)));
563
    func->toggle(xpBlueAction, boost::bind(&TaskPanelView::on_rbXPBlueScheme_toggled, this, bp::_1));
564

565
    QAction* xpBlue2Action = new QAction(this);
566
    connect(ui->rbXPBlue2Scheme, SIGNAL(toggled(bool)), xpBlue2Action, SIGNAL(toggled(bool)));
567
    func->toggle(xpBlue2Action, boost::bind(&TaskPanelView::on_rbXPBlue2Scheme_toggled, this, bp::_1));
568

569
    QAction* vistaAction = new QAction(this);
570
    connect(ui->rbVistaScheme, SIGNAL(toggled(bool)), vistaAction, SIGNAL(toggled(bool)));
571
    func->toggle(vistaAction, boost::bind(&TaskPanelView::on_rbVistaScheme_toggled, this, bp::_1));
572

573
    QAction* macAction = new QAction(this);
574
    connect(ui->rbMacScheme, SIGNAL(toggled(bool)), macAction, SIGNAL(toggled(bool)));
575
    func->toggle(macAction, boost::bind(&TaskPanelView::on_rbMacScheme_toggled, this, bp::_1));
576

577
    QAction* androidAction = new QAction(this);
578
    connect(ui->rbAndroidScheme, SIGNAL(toggled(bool)), androidAction, SIGNAL(toggled(bool)));
579
    func->toggle(androidAction, boost::bind(&TaskPanelView::on_rbAndroidScheme_toggled, this, bp::_1));
580
    }
581
#endif
582
}
583

584
TaskPanelView::~TaskPanelView()
585
{
586
}
587

588
void TaskPanelView::executeAction()
589
{
590
    QMessageBox::about(0, QString::fromLatin1("Action clicked"), QString::fromLatin1("Do something here :)"));
591
}
592

593
void TaskPanelView::on_rbDefaultScheme_toggled(bool b)
594
{
595
#if defined(QSINT_ACTIONPANEL)
596
    if (b)
597
        static_cast<QSint::ActionPanel *>(actionGroup)->setScheme(QSint::ActionPanelScheme::defaultScheme());
598
#endif
599
}
600

601
void TaskPanelView::on_rbXPBlueScheme_toggled(bool b)
602
{
603
#if defined(QSINT_ACTIONPANEL)
604
    if (b)
605
        static_cast<QSint::ActionPanel *>(actionGroup)->setScheme(QSint::WinXPPanelScheme::defaultScheme());
606
#endif
607
}
608

609
void TaskPanelView::on_rbXPBlue2Scheme_toggled(bool b)
610
{
611
#if defined(QSINT_ACTIONPANEL)
612
    if (b)
613
        static_cast<QSint::ActionPanel *>(actionGroup)->setScheme(QSint::WinXPPanelScheme2::defaultScheme());
614
#endif
615
}
616

617
void TaskPanelView::on_rbVistaScheme_toggled(bool b)
618
{
619
#if defined(QSINT_ACTIONPANEL)
620
    if (b)
621
        static_cast<QSint::ActionPanel *>(actionGroup)->setScheme(QSint::WinVistaPanelScheme::defaultScheme());
622
#endif
623
}
624

625
void TaskPanelView::on_rbMacScheme_toggled(bool b)
626
{
627
#if defined(QSINT_ACTIONPANEL)
628
    if (b)
629
        static_cast<QSint::ActionPanel *>(actionGroup)->setScheme(QSint::MacPanelScheme::defaultScheme());
630
#endif
631
}
632

633
void TaskPanelView::on_rbAndroidScheme_toggled(bool b)
634
{
635
#if defined(QSINT_ACTIONPANEL)
636
    if (b)
637
        static_cast<QSint::ActionPanel *>(actionGroup)->setScheme(QSint::AndroidPanelScheme::defaultScheme());
638
#endif
639
}
640

641
//#include "moc_TaskPanelView.cpp"
642

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.