AgendaPlug::AgendaPlug(QDate date, QWidget *parent) : TemporalPlug(parent), ui(new Ui::AgendaPlug) { ui->setupUi(this); this->setGlobalDate(date); this->date = fromGlobalDate(date); // Set up menu actions QAction *todayAction = new QAction(tr("Jump to today"), this); QAction *jumpAction = new QAction(tr("Jump to"), this); QAction *eventAction = new QAction(tr("New event"), this); actions.append(todayAction); actions.append(jumpAction); actions.append(eventAction); connect(todayAction, SIGNAL(triggered()), this, SLOT(gotoToday())); connect(jumpAction, SIGNAL(triggered()), this, SLOT(selectDay())); connect(eventAction, SIGNAL(triggered()), ui->componentList, SLOT(newEvent())); }
Tools::Tools(bool thisIsABackup, QWidget *parent) : QToolBar(parent) { // This variable holds whether the toolbar is used for a backup or not (add and edit buttons disabled for backups) this->thisIsABackup = thisIsABackup; this->setFloatable(false); this->setMovable(false); this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->setIconSize(QSize(20,20)); addBooking = new QToolButton; addBooking->setIcon(QIcon(":/images/add.png")); addBooking->setText("Add &New"); addBooking->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); addBooking->setStyleSheet("font-size: 11pt; font-weight: bold"); addBooking->setFixedHeight(40); addBooking->setStatusTip("Add a new booking"); if(thisIsABackup) addBooking->setEnabled(false); editBooking = new QToolButton; editBooking->setIcon(QIcon(":/images/edit.png")); editBooking->setText("&Edit"); editBooking->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); editBooking->setStyleSheet("font-size: 11pt; font-weight: bold"); editBooking->setFixedHeight(40); editBooking->setStatusTip("Edit Booking"); if(thisIsABackup) editBooking->setEnabled(false); gotoToday_but = new QToolButton; gotoToday_but->setIcon(QIcon(":/images/calendar.png")); gotoToday_but->setText("Go to &Today"); gotoToday_but->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); gotoToday_but->setStyleSheet("font-size: 11pt; font-weight: bold"); gotoToday_but->setFixedHeight(40); gotoToday_but->setStatusTip("Go to Today"); currentDate = QDate::currentDate(); gotoPrev = new QToolButton; gotoPrev->setIcon(QIcon(":/images/left.png")); gotoPrev->setStatusTip("Go to previous day"); gotoPrev->setFixedSize(50,40); gotoPrev->setShortcut(QKeySequence("Alt+Left")); gotoNext = new QToolButton; gotoNext->setIcon(QIcon(":/images/right.png")); gotoNext->setStatusTip("Go to next day"); gotoNext->setFixedSize(50,40); gotoNext->setShortcut(QKeySequence("Alt+Right")); curDate = new QToolButton; curDate->setStatusTip("Select date from calendar"); curDate->setText(QDate::currentDate().toString("dddd, dd MMM yyyy")); curDate->setStyleSheet("font-size: 11pt; font-weight: bold"); curDate->setFixedSize(220,40); curDate->setPopupMode(QToolButton::InstantPopup); curDate->setShortcut(QKeySequence("Alt+C")); cal = new QCalendarWidget; cal->setMinimumDate(QDate(QDate::currentDate().year()-100,1,1)); cal->setMaximumDate(QDate(QDate::currentDate().year()+100,12,31)); cal->setFixedWidth(400); cal->setFixedHeight(300); cal->setGridVisible(true); cal->setStyleSheet("font-size: 12pt; font-weight: bold"); QTextCharFormat format; format.setFontWeight(QFont::Bold); format.setBackground(QBrush(QColor(220,220,220))); cal->setHeaderTextFormat(format); m = new QMenu; QWidgetAction *a = new QWidgetAction(m); a->setDefaultWidget(cal); m->addAction(a); curDate->setMenu(m); m->installEventFilter(this); connect(m, SIGNAL(aboutToShow()), this, SLOT(clickForCalendar())); showCancelled = new QCheckBox("Also show cancelled bookings"); filterAdv = new QToolButton; filterAdv->setCheckable(true); filterAdv->setText("&Search"); filterAdv->setIcon(QIcon(":/images/search.png")); filterAdv->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); filterAdv->setStyleSheet("font-size: 11pt; font-weight: bold"); filterAdv->setFixedHeight(40); filter = new CustomLineEdit; filter->setStyleSheet("font-size: 11pt"); this->addWidget(addBooking); this->addSeparator(); this->addWidget(editBooking); this->addSeparator(); this->addWidget(gotoToday_but); this->addWidget(gotoPrev); this->addWidget(curDate); this->addWidget(gotoNext); QWidget *separator1 = new QWidget; separator1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QWidget *separator2 = new QWidget; separator2->setFixedWidth(10); QWidget *separator3 = new QWidget; separator3->setFixedWidth(10); this->addWidget(separator1); this->addWidget(filterAdv); this->addWidget(filter); this->addWidget(separator2); this->addSeparator(); this->addWidget(separator3); connect(gotoToday_but, SIGNAL(clicked()), this, SLOT(gotoToday())); connect(gotoNext, SIGNAL(clicked()), this, SLOT(nextDay())); connect(gotoPrev, SIGNAL(clicked()), this, SLOT(prevDay())); connect(cal, SIGNAL(clicked(QDate)), this, SLOT(dateSelected())); connect(filter, SIGNAL(textChanged(QString)), this, SIGNAL(setFilter(QString))); }