Beispiel #1
0
bool VideoPreview::showConfigDialog(QWidget *parent)
{
    VideoPreviewConfigDialog d(parent);

    d.setVideoFile(videoFile());
    d.setDVDDevice(DVDDevice());
    d.setCols(cols());
    d.setRows(rows());
    d.setInitialStep(initialStep());
    d.setMaxWidth(maxWidth());
    d.setDisplayOSD(displayOSD());
    d.setAspectRatio(aspectRatio());
    d.setFormat(extractFormat());
    d.setSaveLastDirectory(save_last_directory);

    if (d.exec() == QDialog::Accepted) {
        setVideoFile(d.videoFile());
        setDVDDevice(d.DVDDevice());
        setCols(d.cols());
        setRows(d.rows());
        setInitialStep(d.initialStep());
        setMaxWidth(d.maxWidth());
        setDisplayOSD(d.displayOSD());
        setAspectRatio(d.aspectRatio());
        setExtractFormat(d.format());
        save_last_directory = d.saveLastDirectory();

        return true;
    }

    return false;
}
Beispiel #2
0
void Minimap::setMap(Map *map)
{
    // Set the title for the Minimap
    std::string caption;

    if (map)
        caption = map->getName();

    if (caption.empty())
        caption = _("Map");

    minimap->setCaption(caption);

    // Adapt the image
    if (mMapImage)
    {
        mMapImage->decRef();
        mMapImage = 0;
    }

    if (map)
    {
        ResourceManager *resman = ResourceManager::getInstance();
        mMapImage = resman->getImage(map->getProperty("minimap"));
    }

    if (mMapImage)
    {
        const int offsetX = 2 * getPadding();
        const int offsetY = getTitleBarHeight() + getPadding();
        const int titleWidth = getFont()->getWidth(getCaption()) + 15;
        const int mapWidth = mMapImage->getWidth() < 100 ?
                             mMapImage->getWidth() + offsetX : 100;
        const int mapHeight = mMapImage->getHeight() < 100 ?
                              mMapImage->getHeight() + offsetY : 100;

        setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
        setMinHeight(mapHeight);

        mWidthProportion = (float) mMapImage->getWidth() / map->getWidth();
        mHeightProportion = (float) mMapImage->getHeight() / map->getHeight();

        setMaxWidth(mMapImage->getWidth() > titleWidth ?
                    mMapImage->getWidth() + offsetX : titleWidth);
        setMaxHeight(mMapImage->getHeight() + offsetY);

        setDefaultSize(getX(), getY(), getWidth(), getHeight());
        resetToDefaultSize();

        if (mShow)
            setVisible(true);
    }
    else
    {
        if (!isSticky())
            setVisible(false);
    }
}
Beispiel #3
0
MibitDialog::MibitDialog( QWidget *parent, const QString &msg, const QString &file, const QPixmap &icon, AnimationType animation )
        : QSvgWidget( parent )
{
    if (file != 0) setSVG(file);

    m_parent = parent;
    animType = animation;
    setMinimumHeight(100);
    setFixedSize(0,0); //until show we grow it
    setMaxHeight(maxH); //default sizes
    setMaxWidth(maxW);
    animRate = 500; //default animation speed (half second rate).
    shakeTimeToLive = 0;
    par = false; parTimes = 0;


    img      = new QLabel();
    hLayout   = new QHBoxLayout();
    vLayout  = new QVBoxLayout();
    text     = new QLabel(msg);
    btnClose = new QPushButton("Close"); ///TODO: what about translations???
    shakeTimer = new QTimer(this);
    shakeTimer->setInterval(20);


    img->setPixmap(icon);
    img->setMaximumHeight(54); //the icon size is hardcoded now.
    img->setMaximumWidth(54);
    img->setAlignment(Qt::AlignLeft);
    img->setMargin(4);

    btnClose->setMaximumWidth(120);

    setLayout(vLayout);
    text->setWordWrap(true);
    text->setAlignment(Qt::AlignJustify|Qt::AlignVCenter);
    text->setMargin(5);


    hLayout->addWidget(img,0,Qt::AlignCenter);
    hLayout->addWidget(text,1,Qt::AlignCenter);
    vLayout->addLayout(hLayout,2);
    vLayout->addWidget(btnClose,1,Qt::AlignCenter);
    timeLine  = new QTimeLine(animRate, this);
    wTimeLine = new QTimeLine(2000, this);
    wTimeLine->setFrameRange(90,190);
    wTimeLine->setCurveShape(QTimeLine::CosineCurve);
    connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(animate(int)));
    connect(wTimeLine, SIGNAL(frameChanged(int)), this, SLOT(waveIt(int)));
    connect(btnClose,SIGNAL(clicked()),this, SLOT(hideDialog()));
    connect(timeLine,SIGNAL(finished()), this, SLOT(onAnimationFinished()));
    connect(shakeTimer,SIGNAL(timeout()), this, SLOT(shakeIt()));
}
Beispiel #4
0
void HTMLClueH::calcSize( HTMLClue *parent )
{
    // make sure children are properly sized
    setMaxWidth( max_width );

    HTMLClue::calcSize( parent );
    
    HTMLObject *obj;
    int lmargin = 0;
    
    if ( parent )
	lmargin = parent->getLeftMargin( getYPos() );

    width = lmargin + indent;
    descent = 0;
    ascent = 0;

    int a = 0;
    int d = 0;
    for ( obj = head; obj != 0; obj = obj->next() )
    {
    	obj->fitLine( (obj == head), true, -1);
	obj->setXPos( width );
	width += obj->getWidth();
	if ( obj->getAscent() > a )
	    a = obj->getAscent();
	if ( obj->getDescent() > d )
	    d = obj->getDescent();
    }

    ascent = a+d;

    switch ( valign )
    {
	case Top:
	    for ( obj = head; obj != 0; obj = obj->next() )
		obj->setYPos( obj->getAscent() );
	    break;

	case VCenter:
	    for ( obj = head; obj != 0; obj = obj->next() )
		obj->setYPos( ascent/2 );
	    break;

	default:
	    for ( obj = head; obj != 0; obj = obj->next() )
		obj->setYPos( ascent - d );
    }
}
Beispiel #5
0
ShortcutWindow::ShortcutWindow(const std::string &title,
                               ShortcutContainer *content)
{
    setWindowName(title);
    // no title presented, title bar is padding so window can be moved.
    gcn::Window::setTitleBarHeight(gcn::Window::getPadding());
    setShowTitle(false);
    setResizable(true);
    setDefaultVisible(false);
    setSaveVisible(true);
    setupWindow->registerWindowForReset(this);

    mItems = content;

    const int border = SCROLL_PADDING * 2 + getPadding() * 2;
    setMinWidth(mItems->getBoxWidth() + border);
    setMinHeight(mItems->getBoxHeight() + border);
    setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border);
    setMaxHeight(mItems->getBoxHeight() * mItems->getMaxItems() + border);

    setDefaultSize(mItems->getBoxWidth() + border, mItems->getBoxHeight() *
                   mItems->getMaxItems() + border, ImageRect::LOWER_RIGHT,
                   mBoxesWidth, 0);

    mBoxesWidth += mItems->getBoxWidth() + border;

    mScrollArea = new ScrollArea(mItems);
    mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
    mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
    mScrollArea->setOpaque(false);

    place(0, 0, mScrollArea, 5, 5).setPadding(0);

    Layout &layout = getLayout();
    layout.setRowHeight(0, Layout::AUTO_SET);
    layout.setMargin(0);

    loadWindowState();
}
Beispiel #6
0
void VideoPreview::loadSettings()
{
    qDebug("VideoPreview::loadSettings");

    set->beginGroup("videopreview");

    setCols(set->value("columns", cols()).toInt());
    setRows(set->value("rows", rows()).toInt());
    setInitialStep(set->value("initial_step", initialStep()).toInt());
    setMaxWidth(set->value("max_width", maxWidth()).toInt());
    setDisplayOSD(set->value("osd", displayOSD()).toBool());
    setExtractFormat((ExtractFormat) set->value("format", extractFormat()).toInt());
    save_last_directory = set->value("save_last_directory", save_last_directory).toBool();
    last_directory = set->value("last_directory", last_directory).toString();

    setVideoFile(set->value("filename", videoFile()).toString());
    setDVDDevice(set->value("dvd_device", DVDDevice()).toString());

    toggleInfoAct->setChecked(set->value("show_info", true).toBool());

    set->endGroup();
}
Beispiel #7
0
ShortcutWindow::ShortcutWindow(ShortcutContainer *content):
    Window("", false, NULL, "graphics/gui/gui.xml", true)
{
    // no title presented, title bar is padding so window can be moved.
    gcn::Window::setTitleBarHeight(gcn::Window::getPadding());
    setWindowName(content->getShortcutHandler()->getPrefix());
    setShowTitle(false);
    setResizable(true);

    mItems = content;

    const int border = SCROLL_PADDING * 2 + getPadding() * 2;

    setMinWidth(mItems->getBoxWidth() + border);
    setMinHeight(mItems->getBoxHeight() + border);
    setMaxWidth(mItems->getBoxWidth() * mItems->getMaxShortcuts() + border);
    setMaxHeight(mItems->getBoxHeight() * mItems->getMaxShortcuts() + border);

    setDefaultSize(mItems->getBoxWidth() + border, (mItems->getBoxHeight() *
                   mItems->getMaxShortcuts()) + border, ImageRect::LOWER_RIGHT,
                   -mInstances * (mItems->getBoxWidth() + 2 * getPadding()), 0);

    mInstances++;

    mScrollArea = new ScrollArea(mItems);
    mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
    mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
    mScrollArea->setOpaque(false);

    place(0, 0, mScrollArea, 5, 5).setPadding(0);

    Layout &layout = getLayout();
    layout.setRowHeight(0, Layout::AUTO_SET);
    layout.setMargin(0);

    loadWindowState();
}
Beispiel #8
0
void Tasty::_init()
{
#ifdef QT_DEBUG
    static bool inited = false;
    Q_ASSERT(!inited);
    inited = true;

    auto now = QDateTime::currentMSecsSinceEpoch();
#endif

    Bayes::instance(this);

    _engine     = new QQmlApplicationEngine(this);
    _settings   = new Settings(this);
    _manager    = _engine->networkAccessManager();
    _pusher     = new PusherClient(this);
    _dataCache  = new TastyDataCache;

    _entryImageWidth   = _settings->maxImageWidth();
    _commentImageWidth = _entryImageWidth;

    Q_TEST(connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
                   this, SLOT(_saveOrReconnect(Qt::ApplicationState))));

    Q_TEST(connect(_manager, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)),
                   this, SLOT(_showNetAccessibility(QNetworkAccessManager::NetworkAccessibility))));

    Q_TEST(connect(_pusher, SIGNAL(unreadChats(int)),          this, SLOT(_setUnreadChats(int))));
    Q_TEST(connect(_pusher, SIGNAL(unreadNotifications(int)),  this, SLOT(_setUnreadNotifications(int))));
    Q_TEST(connect(_pusher, SIGNAL(unreadFriendsEntry(int)),   this, SLOT(_incUnreadFriendsEntries())));

    QQuickStyle::setStyle("Material");

    qmlRegisterType<FeedModel>          ("org.binque.taaasty", 1, 0, "FeedModel");
    qmlRegisterType<CalendarModel>      ("org.binque.taaasty", 1, 0, "CalendarModel");
    qmlRegisterType<CommentsModel>      ("org.binque.taaasty", 1, 0, "CommentsModel");
    qmlRegisterType<AttachedImagesModel>("org.binque.taaasty", 1, 0, "AttachedImagesModel");
    qmlRegisterType<UsersModel>         ("org.binque.taaasty", 1, 0, "UsersModel");
    qmlRegisterType<MessagesModel>      ("org.binque.taaasty", 1, 0, "MessagesModel");
    qmlRegisterType<FlowsModel>         ("org.binque.taaasty", 1, 0, "FlowsModel");
    qmlRegisterType<TagsModel>          ("org.binque.taaasty", 1, 0, "TagsModel");

    qmlRegisterType<Entry>          ("org.binque.taaasty", 1, 0, "TlogEntry");
    qmlRegisterType<CalendarEntry>  ("org.binque.taaasty", 1, 0, "CalendarEntry");
    qmlRegisterType<Comment>        ("org.binque.taaasty", 1, 0, "Comment");
    qmlRegisterType<User>           ("org.binque.taaasty", 1, 0, "User");
    qmlRegisterType<Author>         ("org.binque.taaasty", 1, 0, "Author");
    qmlRegisterType<Tlog>           ("org.binque.taaasty", 1, 0, "Tlog");
    qmlRegisterType<Rating>         ("org.binque.taaasty", 1, 0, "Rating");
    qmlRegisterType<AttachedImage>  ("org.binque.taaasty", 1, 0, "AttachedImage");
    qmlRegisterType<Media>          ("org.binque.taaasty", 1, 0, "Media");
    qmlRegisterType<Notification>   ("org.binque.taaasty", 1, 0, "Notification");
    qmlRegisterType<Message>        ("org.binque.taaasty", 1, 0, "Message");
    qmlRegisterType<MessageBase>    ("org.binque.taaasty", 1, 0, "MessageBase");
    qmlRegisterType<Conversation>   ("org.binque.taaasty", 1, 0, "Chat");
    qmlRegisterType<Flow>           ("org.binque.taaasty", 1, 0, "Flow");

    qmlRegisterType<TextHandler>    ("org.binque.taaasty", 1, 0, "TextHandler");
    qmlRegisterType<Poster>         ("org.binque.taaasty", 1, 0, "Poster");

    qmlRegisterType<CachedImage>("ImageCache", 2, 0, "CachedImage");

    auto root = _engine->rootContext();
    root->setContextProperty("Tasty", this);
    root->setContextProperty("Settings", _settings);

    auto notifs = NotificationsModel::instance(this);
    root->setContextProperty("NotifsModel", notifs);

    auto friendActivity = NotificationsModel::friendActivity(this);
    root->setContextProperty("FriendActivityModel", friendActivity);

    auto chats = ChatsModel::instance(this);
    root->setContextProperty("ChatsModel", chats);

    auto cache = CacheManager::instance(_manager);
    cache->setMaxWidth(_settings->maxImageWidth());
    cache->setAutoloadOverWifi(_settings->loadImagesOverWifi());
    cache->setMaxLoadSize(_settings->maxLoadImageSize());
    root->setContextProperty("Cache", cache);

    Q_TEST(QObject::connect(_settings, SIGNAL(loadImagesOverWifiChanged(bool)), cache, SLOT(setAutoloadOverWifi(bool))));
    Q_TEST(QObject::connect(_settings, SIGNAL(maxLoadImageSizeChanged(int)),    cache, SLOT(setMaxLoadSize(int))));

    auto bayes = Bayes::instance();
    root->setContextProperty("Bayes", bayes);

    auto trainer = bayes->trainer();
    root->setContextProperty("Trainer", trainer);

#ifdef Q_OS_ANDROID
    float density = 160;
#else
    float density = 267; // test
#endif

    double scale = density < 180 ? 1 :
                   density < 270 ? 1.5 :
                   density < 360 ? 2 : 3;

    root->setContextProperty("mm", density / 25.4); // N900: 1 mm = 10.5 px; Q10: 12.9
    root->setContextProperty("pt", 1);
    root->setContextProperty("dp", scale); // N900: 1.5; Q10: 2
    root->setContextProperty("sp", density / 160); // scaleable pixels

    root->setContextProperty("builtAt", QString::fromLatin1(__DATE__));

    _engine->setBaseUrl(QStringLiteral("qrc:/qml/"));
    _engine->load(QUrl(QStringLiteral("main.qml")));

#ifdef QT_DEBUG
    auto ms = QDateTime::currentMSecsSinceEpoch() - now;
    qDebug() << "Started in" << ms << "ms";
#endif
}
void TaskWidgetItem::setItemInfo()
{

    m_completed = new Plasma::CheckBox(this);
    m_completed->setChecked(m_todo->isCompleted());
    m_completed->setMaximumSize(25, 25);

    m_layout->addItem(m_completed, 0, 0);

    connect(m_completed, SIGNAL(toggled(bool)), SLOT(setCompleted(bool)));

    if (m_todo->hasDueDate()) {

        m_date = new Plasma::IconWidget(this);
        m_date->setOrientation(Qt::Horizontal);

        m_date->setText(m_todo->dtDue().toString(KDateTime::LocalDate));
        m_date->setMaximumHeight(15);

        setColorForDate();

        m_layout->addItem(m_date, 0, 1);

    }

    m_name = new Plasma::IconWidget(this);

    m_name->setText(m_todo->summary());
    m_name->setOrientation(Qt::Horizontal);

    m_name->setMaximumHeight(15);

    if (m_completed->isChecked()) {

        m_name->setIcon(KIcon("dialog-ok"));
    }

    if (m_date) {

        m_layout->addItem(m_name, 1, 1);

    } else {

        m_layout->addItem(m_name, 0, 1);

    }

    Plasma::ToolTipContent content(m_todo->summary(), m_todo->description());
    
    if (m_todo->isCompleted()) {
	
	content.setImage(KIcon("dialog-ok"));
	
    } else {
	
	content.setImage(KIcon("edit-delete"));
	
    }
    
    Plasma::ToolTipManager::self()->setContent(m_name, content);
    
    connect(m_name, SIGNAL(clicked()), SLOT(editTask()));

    if (m_date) {

	Plasma::ToolTipManager::self()->setContent(m_date, content);
	
        connect(m_date, SIGNAL(clicked()), SLOT(editTask()));

    }
    
    setMaxWidth(((TaskWidget*)parentWidget())->taskWidth());

}
Beispiel #10
0
void controlUC::setAttribute(PCWSTR pstrName, PCWSTR pstrValue)
{
	if( _tcscmp(pstrName, L"pos") == 0 ) {
		RECT rcPos = { 0 };
		PWSTR pstr = NULL;
		rcPos.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcPos.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcPos.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcPos.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);    
		SIZE szXY = {rcPos.left >= 0 ? rcPos.left : rcPos.right, rcPos.top >= 0 ? rcPos.top : rcPos.bottom};
		setFixedXY(szXY);
		setFixedWidth(rcPos.right - rcPos.left);
		setFixedHeight(rcPos.bottom - rcPos.top);
	}
	else if( _tcscmp(pstrName, L"relativepos") == 0 ) {
		SIZE szMove,szZoom;
		PWSTR pstr = NULL;
		szMove.cx = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		szMove.cy = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		szZoom.cx = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		szZoom.cy = _tcstol(pstr + 1, &pstr, 10); assert(pstr); 
		setRelativePos(szMove,szZoom);
	}
	else if( _tcscmp(pstrName, L"padding") == 0 ) {
		RECT rcPadding = { 0 };
		PWSTR pstr = NULL;
		rcPadding.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcPadding.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcPadding.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);    
		setPadding(rcPadding);
	}
	else if( _tcscmp(pstrName, L"bkcolor") == 0 || _tcscmp(pstrName, L"bkcolor1") == 0 ) {
		while( *pstrValue > L'\0' && *pstrValue <= L' ')  pstrValue = ::CharNext(pstrValue);
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		PWSTR pstr = NULL;
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setBkColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"bordercolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		PWSTR pstr = NULL;
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setBorderColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"focusbordercolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		PWSTR pstr = NULL;
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setFocusBorderColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"bordersize") == 0 ) setBorderSize(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"borderround") == 0 ) {
		SIZE cxyRound = { 0 };
		PWSTR pstr = NULL;
		cxyRound.cx = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		cxyRound.cy = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);     
		setBorderRound(cxyRound);
	}
	else if( _tcscmp(pstrName, L"width") == 0 ) setFixedWidth(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"height") == 0 ) setFixedHeight(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"minwidth") == 0 ) setMinWidth(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"minheight") == 0 ) setMinHeight(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"maxwidth") == 0 ) setMaxWidth(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"maxheight") == 0 ) setMaxHeight(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"name") == 0 ) setName(pstrValue);
	else if( _tcscmp(pstrName, L"text") == 0 ) setText(pstrValue);
	else if( _tcscmp(pstrName, L"tooltip") == 0 ) setToolTip(pstrValue);
	else if( _tcscmp(pstrName, L"userdata") == 0 ) setUserData(pstrValue);
	else if( _tcscmp(pstrName, L"enabled") == 0 ) setEnabled(_tcscmp(pstrValue, L"true") == 0);
	else if( _tcscmp(pstrName, L"mouse") == 0 ) setMouseEnabled(_tcscmp(pstrValue, L"true") == 0);
	else if( _tcscmp(pstrName, L"visible") == 0 ) setVisible(_tcscmp(pstrValue, L"true") == 0);
	else if( _tcscmp(pstrName, L"float") == 0 ) setFloat(_tcscmp(pstrValue, L"true") == 0);
	else if( _tcscmp(pstrName, L"shortcut") == 0 ) setShortcut(pstrValue[0]);
	else if( _tcscmp(pstrName, L"menu") == 0 ) setContextMenuUsed(_tcscmp(pstrValue, L"true") == 0);
}