Skip to content
RequestInterface.h 2.82 KiB
Newer Older
/*
 * Copyright (C) 2017  Kevin Whitaker <eyecreate@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef REQUESTINTERFACE_H
#define REQUESTINTERFACE_H

#include <Wt/WContainerWidget>
#include "../WebInterface.h"
#include <Wt/WPushButton>
#include <Wt/WHBoxLayout>
#include <Wt/WVBoxLayout>
#include <Wt/WGridLayout>
#include <Wt/WLineEdit>
#include "TrackDetails.h"

class RequestInterface : public Wt::WContainerWidget
{
public:
    RequestInterface(WebInterface* app);
    WebInterface* app;
    class RequestItem : public Wt::WContainerWidget
    {
    public:
        TrackDetails* track;
        Wt::WHBoxLayout* layout;
        Wt::WPushButton* voteBtn;
        RequestInterface* parent;
        void requestClicked() {
            this->parent->trackRequestClicked(track->extractTrackFromDetails());
        };
        RequestItem(RequestInterface* parent, AudioTrack track) {
            this->track = new TrackDetails();
            this->track->updateWithTrackDetails(track);
            this->track->changeBackgroundColor(Wt::WColor("gainsboro"));
            layout = new Wt::WHBoxLayout();
            voteBtn = new Wt::WPushButton();
            this->parent = parent;
            
            this->setLayout(layout);
            voteBtn->setTextFormat(Wt::XHTMLText);
            voteBtn->decorationStyle().font().setFamily(Wt::WFont::Default,"FontAwesome");
            voteBtn->setText("&#61525;");
            layout->addWidget(this->track,1,Wt::AlignmentFlag::AlignMiddle | Wt::AlignmentFlag::AlignLeft);
            layout->addWidget(voteBtn,0,Wt::AlignmentFlag::AlignMiddle | Wt::AlignmentFlag::AlignRight);
            voteBtn->clicked().connect(this, &RequestItem::requestClicked);
        };
    };
    
    Wt::WVBoxLayout* mainLayout;
    Wt::WHBoxLayout* searchLayout;
    Wt::WLineEdit* searchBox;
    Wt::WPushButton* searchBtn;
    Wt::WGridLayout* resultLayout;
    
    void trackRequestClicked(AudioTrack track);