Skip to content

Commit

Permalink
timeout
Browse files Browse the repository at this point in the history
sb0y committed Apr 22, 2015
1 parent 261e817 commit c7e268c
Showing 5 changed files with 122 additions and 28 deletions.
2 changes: 2 additions & 0 deletions src/core.cpp
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ void core::defaultSettings()
{
{ "WEB/site", "bagrintsev.me" },
{ "WEB/accessToken", "" },
{ "main/timeout", "300" },
{ NULL, NULL } // end
};

@@ -91,6 +92,7 @@ int core::exec()
if ( NULL == sc )
{
sc = new screenshot ( this );
sc->setTimeout ( settings->value ( "main/timeout" ).toInt() );
}

#ifdef WIN32
12 changes: 9 additions & 3 deletions src/screenshot.cpp
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ screenshot::screenshot ( core *c )
main = c;
wg = NULL, dg = NULL, rg = NULL;
currentGrabber = NULL;
timeout = 0;
}

screenshot::~screenshot()
@@ -33,7 +34,7 @@ int screenshot::shootWindow()
if ( NULL != wg )
{
currentGrabber = wg;
QTimer::singleShot ( 400, this, SLOT ( startCurrentGrabber() ) );
QTimer::singleShot ( timeout, this, SLOT ( startCurrentGrabber() ) );
}

return 1;
@@ -51,7 +52,7 @@ int screenshot::shootDesktop ( bool now )
dg->start();
} else {
currentGrabber = dg;
QTimer::singleShot ( 400, this, SLOT ( startCurrentGrabber() ) );
QTimer::singleShot ( timeout, this, SLOT ( startCurrentGrabber() ) );
}
}

@@ -66,7 +67,7 @@ int screenshot::shootRectangle()
if ( NULL != rg )
{
currentGrabber = rg;
QTimer::singleShot ( 400, this, SLOT ( startCurrentGrabber() ) );
QTimer::singleShot ( timeout, this, SLOT ( startCurrentGrabber() ) );
}

return 1;
@@ -80,3 +81,8 @@ void screenshot::startCurrentGrabber()
currentGrabber = NULL;
}
}

void screenshot::setTimeout ( int val )
{
timeout = val;
}
2 changes: 2 additions & 0 deletions src/screenshot.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ class screenshot : public system
int shootWindow();
int shootDesktop ( bool now = false );
int shootRectangle();
void setTimeout ( int );

grabberBase *wg;
grabberBase *dg;
@@ -33,6 +34,7 @@ class screenshot : public system
private:

grabberBase *currentGrabber;
int timeout;

signals:

2 changes: 2 additions & 0 deletions src/settingsdialog.cpp
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ settingsDialog::settingsDialog ( QWidget *parent ) :
ui->lineToken->setText ( system::getCore()->settings->value ( "WEB/accessToken" ).toString() );
ui->lineSite->setText ( system::getCore()->settings->value ( "WEB/site" ).toString() );

ui->timeout->setValue ( system::getCore()->settings->value ( "main/timeout" ).toInt() );

QObject::connect ( ui->buttonBox, SIGNAL ( accepted() ), this, SLOT ( save() ) );
QObject::connect ( ui->commandLinkButton, SIGNAL ( clicked() ), this, SLOT ( goForToken() ) );
}
132 changes: 107 additions & 25 deletions src/settingsdialog.ui
Original file line number Diff line number Diff line change
@@ -6,10 +6,22 @@
<rect>
<x>0</x>
<y>0</y>
<width>410</width>
<height>320</height>
<width>414</width>
<height>341</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
@@ -19,20 +31,65 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>main</string>
</attribute>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Screenshot timeout</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="timeout">
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>WEB</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You can export your screenshots in World Wide Web directly from here. As hosting uses a site with PHP CMS &lt;a href=&quot;https://github.com/sb0y/sblog&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#01a6d8;&quot;&gt;Sblog&lt;/span&gt;&lt;/a&gt; with module &amp;quot;screenshots&amp;quot;. &lt;br/&gt;You need from there only &lt;a name=&quot;accessToken&quot;/&gt;&lt;a href=&quot;http://bagrintsev.me/screenshot/token&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#01a6d8;&quot;&gt;A&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; text-decoration: underline; color:#01a6d8;&quot;&gt;ccess Token&lt;/span&gt; which grants rights to store data on server.&lt;/p&gt;&lt;p&gt;You will receive a direct link on your picture which can freely be embedded into HTML or BBs forum codes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -47,28 +104,66 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEditFocus" name="lineToken"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Token</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEditFocus" name="lineToken"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You can export your screenshots in World Wide Web directly from here. As hosting uses a site with PHP CMS &lt;a href=&quot;https://github.com/sb0y/sblog&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#01a6d8;&quot;&gt;Sblog&lt;/span&gt;&lt;/a&gt; with module &amp;quot;screenshots&amp;quot;. &lt;br/&gt;You need from there only &lt;a name=&quot;accessToken&quot;/&gt;&lt;a href=&quot;http://bagrintsev.me/screenshot/token&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#01a6d8;&quot;&gt;A&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; text-decoration: underline; color:#01a6d8;&quot;&gt;ccess Token&lt;/span&gt; which grants rights to store data on server.&lt;/p&gt;&lt;p&gt;You will receive a direct link on your picture which can freely be embedded into HTML or BBs forum codes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<item row="4" column="0">
<widget class="QCommandLinkButton" name="commandLinkButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Get the Access Token</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>49</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
@@ -82,19 +177,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCommandLinkButton" name="commandLinkButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Get the Access Token</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>

0 comments on commit c7e268c

Please sign in to comment.