Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
108 KB
Referenced Files
None
Subscribers
None
diff --git a/dialogs/optionsdialog-orig.ui b/dialogs/optionsdialog-orig.ui
deleted file mode 100644
index e076e8d..0000000
--- a/dialogs/optionsdialog-orig.ui
+++ /dev/null
@@ -1,794 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OptionsDialog</class>
- <widget class="QDialog" name="OptionsDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>354</width>
- <height>278</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Options - Lightscreen</string>
- </property>
- <layout class="QVBoxLayout" name="optionsLayout">
- <item>
- <widget class="QTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="generalTab">
- <attribute name="title">
- <string>&amp;General</string>
- </attribute>
- <layout class="QVBoxLayout" name="generalLayout">
- <item>
- <widget class="QGroupBox" name="fileGroupBox">
- <property name="title">
- <string>File</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <layout class="QGridLayout" name="fileGroupBoxLayout">
- <property name="verticalSpacing">
- <number>4</number>
- </property>
- <property name="margin">
- <number>6</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="directoryLabel">
- <property name="text">
- <string>&amp;Directory:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>targetLineEdit</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="targetLineEdit">
- <property name="styleSheet">
- <string notr="true"/>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QPushButton" name="browsePushButton">
- <property name="maximumSize">
- <size>
- <width>60</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../lightscreen.qrc">
- <normaloff>:/icons/OpenFolder</normaloff>:/icons/OpenFolder</iconset>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="filenameLabel">
- <property name="toolTip">
- <string>The prefix for the screenshot file</string>
- </property>
- <property name="text">
- <string>&amp;Filename:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>prefixLineEdit</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <layout class="QHBoxLayout" name="filenameLayout">
- <property name="spacing">
- <number>3</number>
- </property>
- <item>
- <widget class="QLineEdit" name="prefixLineEdit">
- <property name="whatsThis">
- <string>The prefix will be inserted before the &lt;em&gt;Naming&lt;/em&gt; in the screenshot file and it is usually used to distinguish files. It can be left blank.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="namingComboBox">
- <property name="whatsThis">
- <string>The naming is inserted after the prefix and is what makes each screenshot file unique to avoid overwriting.&lt;br /&gt;
-&lt;b&gt;Numeric&lt;/b&gt;: inserts a number in sequence, 1, 2, 3.
-&lt;b&gt;Timestamp&lt;/b&gt;: inserts a unique number (a Unix timestamp) that corresponds with the current time.
-&lt;b&gt;Date&lt;/b&gt;: inserts the current date and time, in the form of dd-MM-yyyy hh.mm.ss.</string>
- </property>
- <item>
- <property name="text">
- <string>(number)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>(date)</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="2">
- <widget class="QPushButton" name="flipPrefixPushButton">
- <property name="icon">
- <iconset resource="../lightscreen.qrc">
- <normaloff>:/icons/PrefixLeft</normaloff>:/icons/PrefixLeft</iconset>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="formatLabel">
- <property name="toolTip">
- <string>The file format for the screenshot</string>
- </property>
- <property name="text">
- <string>F&amp;ormat:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>formatComboBox</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QComboBox" name="formatComboBox">
- <item>
- <property name="text">
- <string>PNG</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>JPG</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>BMP</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="delayLabel">
- <property name="text">
- <string>D&amp;elay:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>delaySpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSpinBox" name="delaySpinBox">
- <property name="whatsThis">
- <string>Selecting anything other than 0 in this option will cause the program to &lt;b&gt;wait&lt;/b&gt; that amount of seconds before taking the screenshot.</string>
- </property>
- <property name="specialValueText">
- <string>none</string>
- </property>
- <property name="accelerated">
- <bool>true</bool>
- </property>
- <property name="correctionMode">
- <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
- </property>
- <property name="suffix">
- <string> seconds</string>
- </property>
- <property name="prefix">
- <string/>
- </property>
- <property name="maximum">
- <number>32767</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>1</width>
- <height>1</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QCheckBox" name="startupCheckBox">
- <property name="whatsThis">
- <string/>
- </property>
- <property name="text">
- <string>&amp;Run Lightscreen at system startup.</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="startupHideLayout">
- <item>
- <spacer name="startupHideSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>15</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QCheckBox" name="startupHideCheckBox">
- <property name="whatsThis">
- <string/>
- </property>
- <property name="text">
- <string>H&amp;ide the main window.</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="hotkeysTab">
- <attribute name="title">
- <string>&amp;Hotkeys</string>
- </attribute>
- <layout class="QGridLayout" name="hotkeyLayout">
- <property name="margin">
- <number>6</number>
- </property>
- <item row="0" column="0">
- <widget class="QCheckBox" name="screenCheckBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Capture the screen</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <spacer name="hotkeySpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QCheckBox" name="windowCheckBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Capture the current window</string>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="HotkeyWidget" name="windowHotkeyWidget">
- <property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QCheckBox" name="windowPickerCheckBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Capture a chosen window</string>
- </property>
- </widget>
- </item>
- <item row="2" column="3">
- <widget class="HotkeyWidget" name="windowPickerHotkeyWidget">
- <property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="areaCheckBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Capture a screen area</string>
- </property>
- </widget>
- </item>
- <item row="3" column="3">
- <widget class="HotkeyWidget" name="areaHotkeyWidget">
- <property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="0" rowspan="2" colspan="4">
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="6" column="0" colspan="2">
- <widget class="QCheckBox" name="openCheckBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Open the program window</string>
- </property>
- </widget>
- </item>
- <item row="5" column="3" rowspan="2">
- <widget class="HotkeyWidget" name="openHotkeyWidget">
- <property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="7" column="0" colspan="2">
- <widget class="QCheckBox" name="directoryCheckBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Open the directory</string>
- </property>
- </widget>
- </item>
- <item row="7" column="3">
- <widget class="HotkeyWidget" name="directoryHotkeyWidget">
- <property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="HotkeyWidget" name="screenHotkeyWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="optionsTab">
- <attribute name="title">
- <string>&amp;Options</string>
- </attribute>
- <layout class="QVBoxLayout" name="optionsLayout_2">
- <property name="margin">
- <number>6</number>
- </property>
- <item>
- <widget class="QCheckBox" name="trayCheckBox">
- <property name="whatsThis">
- <string/>
- </property>
- <property name="text">
- <string>Sho&amp;w a system tray icon.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="hideCheckBox">
- <property name="text">
- <string>&amp;Hide Lightscreen while taking a screenshot.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="magnifyCheckBox">
- <property name="text">
- <string>&amp;Magnify around the mouse in Area mode.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="previewCheckBox">
- <property name="text">
- <string>View a preview of each screenshot.</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="languageLayout">
- <item>
- <widget class="QLabel" name="languageLabel">
- <property name="text">
- <string>&amp;Language:</string>
- </property>
- <property name="buddy">
- <cstring>languageComboBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="languageComboBox"/>
- </item>
- <item>
- <widget class="QLabel" name="moreInformationLabel">
- <property name="whatsThis">
- <string>Click here to go to the Lightscreen homepage to learn more about translations.</string>
- </property>
- <property name="text">
- <string>&lt;a href=&quot;http://lightscreen.sourceforge.net/translation&quot;&gt;More information..&lt;/a&gt;</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="languageSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="notifyLayout">
- <property name="spacing">
- <number>12</number>
- </property>
- <item>
- <widget class="QLabel" name="notifyLabel">
- <property name="text">
- <string>&amp;Notify with:</string>
- </property>
- <property name="buddy">
- <cstring>messageCheckBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="messageCheckBox">
- <property name="whatsThis">
- <string>Shows a completion message once the screenshot is saved, clicking this message takes you to the directory where the screenshot was saved.</string>
- </property>
- <property name="text">
- <string>Tray icon Popup</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="playSoundCheckBox">
- <property name="text">
- <string>&amp;Sound cue</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="qualityLayout">
- <item>
- <widget class="QLabel" name="qualityLabel">
- <property name="text">
- <string>Screenshot &amp;Quality:</string>
- </property>
- <property name="buddy">
- <cstring>qualitySlider</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSlider" name="qualitySlider">
- <property name="whatsThis">
- <string>This slider goes from 0 to 100. 100 being the highest quality and 0 the lowest.&lt;br&gt;
-Quality is related to file size and of course to readability and overall quality of the image.</string>
- </property>
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="qualityValueLabel">
- <property name="text">
- <string>100</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="qualityPercentLabel">
- <property name="text">
- <string>%</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="advancedTab">
- <attribute name="title">
- <string>&amp;Advanced</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="margin">
- <number>6</number>
- </property>
- <item>
- <widget class="QCheckBox" name="saveAsCheckBox">
- <property name="text">
- <string>Choose where and how to &amp;save each screenshot (&quot;&amp;Save as&quot;).</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="clipboardCheckBox">
- <property name="text">
- <string>&amp;Copy the screenshot to the clipboard.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="cursorCheckBox">
- <property name="text">
- <string>Inc&amp;lude the cursor in the screenshot.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="currentMonitorCheckBox">
- <property name="text">
- <string>&amp;Grab only the current monitor.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="optiPngCheckBox">
- <property name="toolTip">
- <string>Opens a new process called OptiPNG which dramatically reduces the file size.</string>
- </property>
- <property name="text">
- <string>O&amp;ptimize PNG screenshots.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="warnHideCheckBox">
- <property name="text">
- <string>Warn when hiding without a tra&amp;y icon.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="updaterCheckBox">
- <property name="text">
- <string>Check for updates regularly.</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>2</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" name="advancedButtonLayout">
- <item>
- <widget class="QPushButton" name="checkUpdatesPushButton">
- <property name="text">
- <string>Chec&amp;k Updates Now</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="advancedButtonSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="aboutPushButton">
- <property name="text">
- <string>About Lightscreen</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="styleSheet">
- <string notr="true"/>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>HotkeyWidget</class>
- <extends>QPushButton</extends>
- <header>widgets/hotkeywidget.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>fileGroupBox</tabstop>
- <tabstop>targetLineEdit</tabstop>
- <tabstop>browsePushButton</tabstop>
- <tabstop>prefixLineEdit</tabstop>
- <tabstop>namingComboBox</tabstop>
- <tabstop>flipPrefixPushButton</tabstop>
- <tabstop>formatComboBox</tabstop>
- <tabstop>delaySpinBox</tabstop>
- <tabstop>startupCheckBox</tabstop>
- <tabstop>trayCheckBox</tabstop>
- <tabstop>hideCheckBox</tabstop>
- <tabstop>magnifyCheckBox</tabstop>
- <tabstop>languageComboBox</tabstop>
- <tabstop>messageCheckBox</tabstop>
- <tabstop>playSoundCheckBox</tabstop>
- <tabstop>qualitySlider</tabstop>
- <tabstop>buttonBox</tabstop>
- </tabstops>
- <resources>
- <include location="../lightscreen.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>OptionsDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>289</x>
- <y>280</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/dialogs/optionsdialog.cpp b/dialogs/optionsdialog.cpp
index e6a8148..c7ef0bc 100644
--- a/dialogs/optionsdialog.cpp
+++ b/dialogs/optionsdialog.cpp
@@ -1,660 +1,660 @@
/*
* Copyright (C) 2011 Christian Kaiser
*
* 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <QCompleter>
#include <QDate>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QDirModel>
#include <QFileDialog>
#include <QKeyEvent>
#include <QMessageBox>
#include <QSettings>
#include <QUrl>
#include <QTimer>
#include <QDebug>
#if defined(Q_WS_WIN)
#include <windows.h>
#endif
#include "optionsdialog.h"
#include "namingdialog.h"
#include "../tools/os.h"
#include "../tools/screenshot.h"
#include "../tools/screenshotmanager.h"
#include "../updater/updater.h"
OptionsDialog::OptionsDialog(QWidget *parent) :
QDialog(parent)
{
ui.setupUi(this);
setModal(true);
if (os::aeroGlass(this)) {
layout()->setMargin(2);
resize(minimumSizeHint());
}
QTimer::singleShot(0, this, SLOT(init()));
QTimer::singleShot(1, this, SLOT(loadSettings()));
}
void OptionsDialog::init()
{
#if !defined(Q_WS_WIN)
ui.cursorCheckBox->setVisible(false);
ui.cursorCheckBox->setChecked(false);
// KDE-specific style tweaks.
if (qApp->style()->objectName() == "oxygen") {
- qDebug() << "OXYGENN YEAAHH";
ui.browsePushButton->setMaximumWidth(30);
ui.namingOptionsButton->setMaximumWidth(30);
ui.fileGroupBox->setFlat(false);
ui.startupGroupBox->setFlat(false);
ui.capturesGroupBox->setFlat(false);
ui.controlGroupBox->setFlat(false);
ui.interfaceGroupBox->setFlat(false);
ui.screenshotsGroupBox->setFlat(false);
ui.previewGroupBox->setFlat(false);
ui.updaterGroupBox->setFlat(false);
- ui.aboutTab->layout()->setMargin(8);
+ ui.optionsTab->layout()->setMargin(4);
+ ui.aboutTab->layout()->setContentsMargins(0, 0, 6, 0);
}
#endif
// Make the scroll area share the Tab Widget background color
QPalette optionsPalette = ui.optionsScrollArea->palette();
optionsPalette.setColor(QPalette::Window, ui.tabWidget->palette().color(QPalette::Base));
ui.optionsScrollArea->setPalette(optionsPalette);
ui.buttonBox->addButton(new QPushButton(" " + tr("Restore Defaults") + " ", this), QDialogButtonBox::ResetRole);
// Set up the autocomplete for the directory.
QCompleter *completer = new QCompleter(this);
completer->setModel(new QDirModel(QStringList(), QDir::Dirs, QDir::Name, completer));
ui.targetLineEdit->setCompleter(completer);
// HotkeyWidget icons.
ui.screenHotkeyWidget->setIcon (QIcon(":/icons/screen"));
ui.windowHotkeyWidget->setIcon (QIcon(":/icons/window"));
ui.windowPickerHotkeyWidget->setIcon(QIcon(":/icons/picker"));
ui.areaHotkeyWidget->setIcon (QIcon(":/icons/area"));
ui.openHotkeyWidget->setIcon (QIcon(":/icons/lightscreen.small"));
ui.directoryHotkeyWidget->setIcon (QIcon(":/icons/folder"));
// Version
ui.versionLabel->setText(tr("Version %1").arg(qApp->applicationVersion()));
setEnabled(false); // We disable the widgets to prevent any user interaction until the settings have loaded.
setUpdatesEnabled(false);
//
// Connections
//
connect(ui.buttonBox , SIGNAL(clicked(QAbstractButton*)), this , SLOT(dialogButtonClicked(QAbstractButton*)));
connect(ui.buttonBox , SIGNAL(accepted()) , this , SLOT(accepted()));
connect(ui.buttonBox , SIGNAL(rejected()) , this , SLOT(rejected()));
connect(ui.namingOptionsButton , SIGNAL(clicked()) , this , SLOT(namingOptions()));
connect(ui.prefixLineEdit , SIGNAL(textChanged(QString)) , this , SLOT(updatePreview()));
connect(ui.formatComboBox , SIGNAL(currentIndexChanged(int)) , this , SLOT(updatePreview()));
connect(ui.namingComboBox , SIGNAL(currentIndexChanged(int)) , this , SLOT(updatePreview()));
connect(ui.browsePushButton , SIGNAL(clicked()) , this , SLOT(browse()));
connect(ui.checkUpdatesPushButton , SIGNAL(clicked()) , this , SLOT(checkUpdatesNow()));
connect(ui.screenCheckBox , SIGNAL(toggled(bool)), ui.screenHotkeyWidget , SLOT(setEnabled(bool)));
connect(ui.areaCheckBox , SIGNAL(toggled(bool)), ui.areaHotkeyWidget , SLOT(setEnabled(bool)));
connect(ui.windowCheckBox , SIGNAL(toggled(bool)), ui.windowHotkeyWidget , SLOT(setEnabled(bool)));
connect(ui.windowPickerCheckBox, SIGNAL(toggled(bool)), ui.windowPickerHotkeyWidget, SLOT(setEnabled(bool)));
connect(ui.openCheckBox , SIGNAL(toggled(bool)), ui.openHotkeyWidget , SLOT(setEnabled(bool)));
connect(ui.directoryCheckBox , SIGNAL(toggled(bool)), ui.directoryHotkeyWidget, SLOT(setEnabled(bool)));
connect(ui.saveAsCheckBox , SIGNAL(toggled(bool)), ui.targetLineEdit , SLOT(setDisabled(bool)));
connect(ui.saveAsCheckBox , SIGNAL(toggled(bool)), ui.browsePushButton , SLOT(setDisabled(bool)));
connect(ui.saveAsCheckBox , SIGNAL(toggled(bool)), ui.directoryLabel , SLOT(setDisabled(bool)));
connect(ui.startupCheckBox , SIGNAL(toggled(bool)), ui.startupHideCheckBox , SLOT(setEnabled(bool)));
connect(ui.qualitySlider , SIGNAL(valueChanged(int)), ui.qualityValueLabel, SLOT(setNum(int)));
connect(ui.trayCheckBox , SIGNAL(toggled(bool)), ui.messageCheckBox , SLOT(setEnabled(bool)));
connect(ui.moreInformationLabel, SIGNAL(linkActivated(QString)) , this, SLOT(openUrl(QString)));
connect(ui.languageComboBox , SIGNAL(currentIndexChanged(QString)), this, SLOT(languageChange(QString)));
connect(ui.mainLabel , SIGNAL(linkActivated(QString)), this, SLOT(openUrl(QString)));
connect(ui.linksLabel, SIGNAL(linkActivated(QString)), this, SLOT(openUrl(QString)));
//
// Languages
//
QDir languages(":/translations");
ui.languageComboBox->addItem("English");
foreach (QString language, languages.entryList()) {
ui.languageComboBox->addItem(language);
}
}
void OptionsDialog::namingOptions()
{
NamingDialog namingDialog((Screenshot::Naming) ui.namingComboBox->currentIndex());
namingDialog.exec();
flipToggled(settings()->value("options/flip").toBool());
updatePreview();
}
QSettings *OptionsDialog::settings() const
{
return ScreenshotManager::instance()->settings();
}
/*
* Slots
*/
void OptionsDialog::accepted()
{
if (hotkeyCollision()) {
QMessageBox::critical(this, tr("Hotkey conflict"), tr("You have assigned the same hotkeys to more than one action."));
return;
}
if (ui.prefixLineEdit->text().contains(QRegExp("[?:\\\\/*\"<>|]"))) {
QMessageBox::critical(this, tr("Filename character error"), tr("The filename can't contain any of the following characters: ? : \\ / * \" < > |"));
return;
}
if (!ui.fileGroupBox->isChecked() && !ui.clipboardCheckBox->isChecked()) {
QMessageBox::critical(this, tr("Final Destination"), tr("You can't take screenshots unless you enable either file saving or the clipboard."));
return;
}
saveSettings();
accept();
}
void OptionsDialog::browse()
{
QString fileName = QFileDialog::getExistingDirectory(this,
tr("Select where you want to save the screenshots"),
ui.targetLineEdit->text());
if (fileName.isEmpty())
return;
ui.targetLineEdit->setText(fileName);
}
void OptionsDialog::checkUpdatesNow()
{
Updater::instance()->checkWithFeedback();
}
void OptionsDialog::dialogButtonClicked(QAbstractButton *button)
{
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::ResetRole) {
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Lightscreen - Options"));
msgBox.setText(tr("Restoring the default options will cause you to lose all of your current configuration."));
msgBox.setIcon(QMessageBox::Warning);
QPushButton *restoreButton = msgBox.addButton(tr("Restore"), QMessageBox::ActionRole);
QPushButton *dontRestoreButton = msgBox.addButton(tr("Don't Restore"), QMessageBox::ActionRole);
msgBox.exec();
Q_UNUSED(restoreButton)
if (msgBox.clickedButton() == dontRestoreButton)
return;
settings()->clear();
loadSettings();
}
}
void OptionsDialog::flipToggled(bool checked)
{
setUpdatesEnabled(false);
ui.filenameLayout->removeWidget(ui.prefixLineEdit);
ui.filenameLayout->removeWidget(ui.namingComboBox);
if (checked) {
ui.filenameLayout->addWidget(ui.namingComboBox);
ui.filenameLayout->addWidget(ui.prefixLineEdit);
}
else {
ui.filenameLayout->addWidget(ui.prefixLineEdit);
ui.filenameLayout->addWidget(ui.namingComboBox);
}
if (ui.prefixLineEdit->text() == "screenshot."
&& checked)
ui.prefixLineEdit->setText(".screenshot");
if (ui.prefixLineEdit->text() == ".screenshot"
&& !checked)
ui.prefixLineEdit->setText("screenshot.");
setUpdatesEnabled(true); // Avoids flicker
}
void OptionsDialog::languageChange(QString language)
{
os::translate(language);
}
void OptionsDialog::openUrl(QString url)
{
if (url == "#aboutqt") {
qApp->aboutQt();
}
else {
QDesktopServices::openUrl(QUrl(url));
}
}
void OptionsDialog::rejected()
{
languageChange(settings()->value("options/language").toString()); // Revert language to default.
}
void OptionsDialog::saveSettings()
{
settings()->beginGroup("file");
settings()->setValue("format", ui.formatComboBox->currentIndex());
settings()->setValue("prefix", ui.prefixLineEdit->text());
settings()->setValue("naming", ui.namingComboBox->currentIndex());
settings()->setValue("target", ui.targetLineEdit->text());
settings()->setValue("enabled", ui.fileGroupBox->isChecked());
settings()->endGroup();
settings()->beginGroup("options");
settings()->setValue("startup", ui.startupCheckBox->isChecked());
settings()->setValue("startupHide", ui.startupHideCheckBox->isChecked());
settings()->setValue("hide", ui.hideCheckBox->isChecked());
settings()->setValue("delay", ui.delaySpinBox->value());
settings()->setValue("tray", ui.trayCheckBox->isChecked());
settings()->setValue("message", ui.messageCheckBox->isChecked());
settings()->setValue("quality", ui.qualitySlider->value());
settings()->setValue("playSound", ui.playSoundCheckBox->isChecked());
// We save the explicit string because addition/removal of language files can cause it to change
settings()->setValue("language", ui.languageComboBox->currentText());
// This settings is inverted because the first iteration of the Updater did not have a settings but instead relied on the messagebox choice of the user.
settings()->setValue("disableUpdater", !ui.updaterCheckBox->isChecked());
settings()->setValue("magnify", ui.magnifyCheckBox->isChecked());
settings()->setValue("cursor", ui.cursorCheckBox->isChecked());
settings()->setValue("saveAs", ui.saveAsCheckBox->isChecked());
settings()->setValue("preview", ui.previewGroupBox->isChecked());
settings()->setValue("previewSize", ui.previewSizeSpinBox->value());
settings()->setValue("previewPosition", ui.previewPositionComboBox->currentIndex());
settings()->setValue("previewAutoclose", ui.previewAutocloseCheckBox->isChecked());
settings()->setValue("previewAutocloseTime", ui.previewAutocloseTimeSpinBox->value());
settings()->setValue("previewAutocloseAction", ui.previewAutocloseActionComboBox->currentIndex());
settings()->setValue("areaAutoclose", ui.areaAutocloseCheckBox->isChecked());
// Advanced
settings()->setValue("disableHideAlert", !ui.warnHideCheckBox->isChecked());
settings()->setValue("clipboard", ui.clipboardCheckBox->isChecked());
settings()->setValue("optipng", ui.optiPngCheckBox->isChecked());
settings()->setValue("currentMonitor", ui.currentMonitorCheckBox->isChecked());
settings()->setValue("replace", ui.replaceCheckBox->isChecked());
//Upload
settings()->setValue("uploadAuto", ui.uploadCheckBox->isChecked());
settings()->endGroup();
settings()->beginGroup("actions");
settings()->beginGroup("screen");
settings()->setValue("enabled", ui.screenCheckBox->isChecked());
settings()->setValue("hotkey", ui.screenHotkeyWidget->hotkey());
settings()->endGroup();
settings()->beginGroup("area");
settings()->setValue("enabled", ui.areaCheckBox->isChecked());
settings()->setValue("hotkey", ui.areaHotkeyWidget->hotkey());
settings()->endGroup();
settings()->beginGroup("window");
settings()->setValue("enabled", ui.windowCheckBox->isChecked());
settings()->setValue("hotkey", ui.windowHotkeyWidget->hotkey());
settings()->endGroup();
settings()->beginGroup("windowPicker");
settings()->setValue("enabled", ui.windowPickerCheckBox->isChecked());
settings()->setValue("hotkey", ui.windowPickerHotkeyWidget->hotkey());
settings()->endGroup();
settings()->beginGroup("open");
settings()->setValue("enabled", ui.openCheckBox->isChecked());
settings()->setValue("hotkey", ui.openHotkeyWidget->hotkey());
settings()->endGroup();
settings()->beginGroup("directory");
settings()->setValue("enabled", ui.directoryCheckBox->isChecked());
settings()->setValue("hotkey", ui.directoryHotkeyWidget->hotkey());
settings()->endGroup();
settings()->endGroup();
}
/*
* Private
*/
void OptionsDialog::loadSettings()
{
settings()->sync();
if (!settings()->contains("file/format")) {
// If there are no settings, get rid of the cancel button so that the user is forced to save them
ui.buttonBox->clear();
ui.buttonBox->addButton(QDialogButtonBox::Ok);
// Move the first option window to the center of the screen, since Windows usually positions it in a random location since it has no visible parent.
if (!(static_cast<QWidget*>(parent())->isVisible()))
move(qApp->desktop()->screen(qApp->desktop()->primaryScreen())->rect().center()-QPoint(height()/2, width()/2));
}
ui.startupCheckBox->toggle();
ui.trayCheckBox->toggle();
ui.previewAutocloseCheckBox->toggle();
settings()->beginGroup("file");
ui.formatComboBox->setCurrentIndex(settings()->value("format", 1).toInt());
ui.prefixLineEdit->setText(settings()->value("prefix", "screenshot.").toString());
ui.namingComboBox->setCurrentIndex(settings()->value("naming", 0).toInt());
ui.targetLineEdit->setText(settings()->value("target", os::getDocumentsPath() + QDir::separator() + "Screenshots").toString()); // Defaults to $HOME$/screenshots
ui.fileGroupBox->setChecked(settings()->value("enabled", true).toBool());
settings()->endGroup();
settings()->beginGroup("options");
ui.startupCheckBox->setChecked(settings()->value("startup", false).toBool());
ui.startupHideCheckBox->setChecked(settings()->value("startupHide", true).toBool());
ui.hideCheckBox->setChecked(settings()->value("hide", true).toBool());
ui.delaySpinBox->setValue(settings()->value("delay", 0).toInt());
flipToggled(settings()->value("flip", false).toBool());
ui.trayCheckBox->setChecked(settings()->value("tray", true).toBool());
ui.messageCheckBox->setChecked(settings()->value("message", true).toBool());
ui.qualitySlider->setValue(settings()->value("quality", 100).toInt());
ui.playSoundCheckBox->setChecked(settings()->value("playSound", false).toBool());
ui.updaterCheckBox->setChecked(!settings()->value("disableUpdater", false).toBool());
ui.magnifyCheckBox->setChecked(settings()->value("magnify", true).toBool());
ui.cursorCheckBox->setChecked(settings()->value("cursor", true).toBool());
ui.saveAsCheckBox->setChecked(settings()->value("saveAs", false).toBool());
ui.previewGroupBox->setChecked(settings()->value("preview", false).toBool());
ui.previewSizeSpinBox->setValue(settings()->value("previewSize", 300).toInt());
ui.previewPositionComboBox->setCurrentIndex(settings()->value("previewPosition", 3).toInt());
ui.previewAutocloseCheckBox->setChecked(settings()->value("previewAutoclose", false).toBool());
ui.previewAutocloseTimeSpinBox->setValue(settings()->value("previewAutocloseTime", 15).toInt());
ui.previewAutocloseActionComboBox->setCurrentIndex(settings()->value("previewAutocloseAction", 0).toInt());
ui.areaAutocloseCheckBox->setChecked(settings()->value("areaAutoclose", false).toBool());
// Advanced
ui.clipboardCheckBox->setChecked(settings()->value("clipboard", true).toBool());
ui.optiPngCheckBox->setChecked(settings()->value("optipng", true).toBool());
ui.warnHideCheckBox->setChecked(!settings()->value("disableHideAlert", false).toBool());
ui.currentMonitorCheckBox->setChecked(settings()->value("currentMonitor", false).toBool());
ui.replaceCheckBox->setChecked(settings()->value("replace", false).toBool());
ui.uploadCheckBox->setChecked(settings()->value("uploadAuto", false).toBool());
#if defined(Q_WS_WIN)
if (!QFile::exists("optipng.exe")) {
ui.optiPngCheckBox->setEnabled(false);
ui.optiPngCheckBox->setChecked(false);
}
#endif
//TODO: Must replace with not-stupid system
QString lang = settings()->value("language").toString();
int index = ui.languageComboBox->findText(lang);
if (index == -1)
index = ui.languageComboBox->findText("English");
ui.languageComboBox->setCurrentIndex(index);
settings()->endGroup();
settings()->beginGroup("actions");
// This toggle is for the first run
ui.screenCheckBox->toggle();
ui.areaCheckBox->toggle();
ui.windowCheckBox->toggle();
ui.windowPickerCheckBox->toggle();
ui.openCheckBox->toggle();
ui.directoryCheckBox->toggle();
settings()->beginGroup("screen");
ui.screenCheckBox->setChecked(settings()->value("enabled", true).toBool());
ui.screenHotkeyWidget->setHotkey(settings()->value("hotkey", QKeySequence(Qt::Key_Print)).value<QKeySequence> ());
settings()->endGroup();
settings()->beginGroup("area");
ui.areaCheckBox->setChecked(settings()->value("enabled").toBool());
ui.areaHotkeyWidget->setHotkey(settings()->value("hotkey", QKeySequence(Qt::CTRL + Qt::Key_Print)).value<QKeySequence> ());
settings()->endGroup();
settings()->beginGroup("window");
ui.windowCheckBox->setChecked(settings()->value("enabled").toBool());
ui.windowHotkeyWidget->setHotkey(settings()->value("hotkey", QKeySequence(Qt::ALT + Qt::Key_Print)).value<QKeySequence> ());
settings()->endGroup();
settings()->beginGroup("windowPicker");
ui.windowPickerCheckBox->setChecked(settings()->value("enabled").toBool());
ui.windowPickerHotkeyWidget->setHotkey(settings()->value("hotkey", QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Print)).value<QKeySequence> ());
settings()->endGroup();
settings()->beginGroup("open");
ui.openCheckBox->setChecked(settings()->value("enabled").toBool());
ui.openHotkeyWidget->setHotkey(settings()->value("hotkey", QKeySequence(Qt::CTRL + Qt::Key_PageUp)).value<QKeySequence> ());
settings()->endGroup();
settings()->beginGroup("directory");
ui.directoryCheckBox->setChecked(settings()->value("enabled").toBool());
ui.directoryHotkeyWidget->setHotkey(settings()->value("hotkey", QKeySequence(Qt::SHIFT + Qt::Key_PageUp)).value<QKeySequence> ());
settings()->endGroup();
settings()->endGroup();
QTimer::singleShot(0, this, SLOT(updatePreview()));
setEnabled(true);
setUpdatesEnabled(true);
}
bool OptionsDialog::hotkeyCollision()
{
// Check for hotkey collision (there's probably a better way to do this...=)
if (ui.screenCheckBox->isChecked()) {
if (ui.screenHotkeyWidget->hotkey() == ui.areaHotkeyWidget->hotkey()
&& ui.areaCheckBox->isChecked())
return true;
if (ui.screenHotkeyWidget->hotkey() == ui.windowHotkeyWidget->hotkey()
&& ui.windowCheckBox->isChecked())
return true;
if (ui.screenHotkeyWidget->hotkey() == ui.windowPickerHotkeyWidget->hotkey()
&& ui.windowPickerCheckBox->isChecked())
return true;
if (ui.screenHotkeyWidget->hotkey() == ui.openHotkeyWidget->hotkey()
&& ui.openCheckBox->isChecked())
return true;
if (ui.screenHotkeyWidget->hotkey() == ui.directoryHotkeyWidget->hotkey()
&& ui.directoryCheckBox->isChecked())
return true;
}
if (ui.areaCheckBox->isChecked()) {
if (ui.areaHotkeyWidget->hotkey() == ui.screenHotkeyWidget->hotkey()
&& ui.screenCheckBox->isChecked())
return true;
if (ui.areaHotkeyWidget->hotkey() == ui.windowHotkeyWidget->hotkey()
&& ui.windowCheckBox->isChecked())
return true;
if (ui.areaHotkeyWidget->hotkey() == ui.windowPickerHotkeyWidget->hotkey()
&& ui.windowPickerCheckBox->isChecked())
return true;
if (ui.areaHotkeyWidget->hotkey() == ui.openHotkeyWidget->hotkey()
&& ui.openCheckBox->isChecked())
return true;
if (ui.areaHotkeyWidget->hotkey() == ui.directoryHotkeyWidget->hotkey()
&& ui.directoryCheckBox->isChecked())
return true;
}
if (ui.windowCheckBox->isChecked()) {
if (ui.windowHotkeyWidget->hotkey() == ui.screenHotkeyWidget->hotkey()
&& ui.screenCheckBox->isChecked())
return true;
if (ui.windowHotkeyWidget->hotkey() == ui.areaHotkeyWidget->hotkey()
&& ui.areaCheckBox->isChecked())
return true;
if (ui.windowHotkeyWidget->hotkey() == ui.windowPickerHotkeyWidget->hotkey()
&& ui.windowPickerCheckBox->isChecked())
return true;
if (ui.windowHotkeyWidget->hotkey() == ui.openHotkeyWidget->hotkey()
&& ui.openCheckBox->isChecked())
return true;
if (ui.windowHotkeyWidget->hotkey() == ui.directoryHotkeyWidget->hotkey()
&& ui.directoryCheckBox->isChecked())
return true;
}
if (ui.openCheckBox->isChecked()) {
if (ui.openHotkeyWidget->hotkey() == ui.screenHotkeyWidget->hotkey()
&& ui.screenCheckBox->isChecked())
return true;
if (ui.openHotkeyWidget->hotkey() == ui.areaHotkeyWidget->hotkey()
&& ui.areaCheckBox->isChecked())
return true;
if (ui.openHotkeyWidget->hotkey() == ui.windowPickerHotkeyWidget->hotkey()
&& ui.windowPickerCheckBox->isChecked())
return true;
if (ui.openHotkeyWidget->hotkey() == ui.windowHotkeyWidget->hotkey()
&& ui.windowCheckBox->isChecked())
return true;
if (ui.openHotkeyWidget->hotkey() == ui.directoryHotkeyWidget->hotkey()
&& ui.directoryCheckBox->isChecked())
return true;
}
if (ui.directoryCheckBox->isChecked()) {
if (ui.directoryHotkeyWidget->hotkey() == ui.screenHotkeyWidget->hotkey()
&& ui.screenCheckBox->isChecked())
return true;
if (ui.directoryHotkeyWidget->hotkey() == ui.areaHotkeyWidget->hotkey()
&& ui.areaCheckBox->isChecked())
return true;
if (ui.directoryHotkeyWidget->hotkey() == ui.windowPickerHotkeyWidget->hotkey()
&& ui.windowPickerCheckBox->isChecked())
return true;
if (ui.directoryHotkeyWidget->hotkey() == ui.windowHotkeyWidget->hotkey()
&& ui.windowCheckBox->isChecked())
return true;
if (ui.directoryHotkeyWidget->hotkey() == ui.openHotkeyWidget->hotkey()
&& ui.openCheckBox->isChecked())
return true;
}
return false;
}
void OptionsDialog::updatePreview()
{
Screenshot::NamingOptions options;
options.naming = (Screenshot::Naming)ui.namingComboBox->currentIndex();
options.flip = settings()->value("options/flip").toBool();
options.leadingZeros = settings()->value("options/naming/leadingZeros").toInt();
options.dateFormat = settings()->value("options/naming/dateFormat").toString();
- ui.namingOptionsButton->setDisabled((options.naming == Screenshot::None));
+ ui.namingOptionsButton->setDisabled((options.naming == Screenshot::Empty));
QString preview = Screenshot::getName(options,
ui.prefixLineEdit->text(),
QDir(ui.targetLineEdit->text()));
preview = QString("%1.%2").arg(preview).arg(ui.formatComboBox->currentText().toLower());
if (preview.length() >= 40) {
preview.truncate(37);
preview.append("...");
}
ui.previewLabel->setText(preview);
}
bool OptionsDialog::event(QEvent* event)
{
if (event->type() == QEvent::LanguageChange) {
ui.retranslateUi(this);
updatePreview();
resize(minimumSizeHint());
}
else if (event->type() == QEvent::Close) {
if (!settings()->contains("file/format")) {
// I'm afraid I can't let you do that, Dave.
event->ignore();
return false;
}
}
return QDialog::event(event);
}
#if defined(Q_WS_WIN)
// Qt does not send the print screen key as a regular QKeyPress event, so we must use the Windows API
bool OptionsDialog::winEvent(MSG *message, long *result)
{
if ((message->message == WM_KEYUP || message->message == WM_SYSKEYUP)
&& message->wParam == VK_SNAPSHOT) {
qApp->postEvent(qApp->focusWidget(), new QKeyEvent(QEvent::KeyPress, Qt::Key_Print, qApp->keyboardModifiers()));
}
return QDialog::winEvent(message, result);
}
#endif
diff --git a/dialogs/optionsdialog.ui b/dialogs/optionsdialog.ui
index f974e7e..0241fc6 100644
--- a/dialogs/optionsdialog.ui
+++ b/dialogs/optionsdialog.ui
@@ -1,1225 +1,1225 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OptionsDialog</class>
<widget class="QDialog" name="OptionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>399</width>
- <height>320</height>
+ <height>341</height>
</rect>
</property>
<property name="windowTitle">
<string>Options - Lightscreen</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="generalTab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="fileGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>File</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="fileGroupBoxLayout">
<property name="verticalSpacing">
<number>4</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="directoryLabel">
<property name="text">
<string>&amp;Directory:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>targetLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="targetLineEdit">
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="browsePushButton">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../lightscreen.qrc">
<normaloff>:/icons/folder</normaloff>:/icons/folder</iconset>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="filenameLabel">
<property name="toolTip">
<string>The prefix for the screenshot file</string>
</property>
<property name="text">
<string>&amp;Filename:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>prefixLineEdit</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="filenameLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QLineEdit" name="prefixLineEdit">
<property name="whatsThis">
<string>The prefix will be inserted before the &lt;em&gt;Naming&lt;/em&gt; in the screenshot file and it is usually used to distinguish files. It can be left blank.</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="namingComboBox">
<property name="whatsThis">
<string>The naming is inserted after the prefix and is what makes each screenshot file unique to avoid overwriting.&lt;br /&gt;
&lt;b&gt;Numeric&lt;/b&gt;: inserts a number in sequence, 1, 2, 3..&lt;br /&gt;
&lt;b&gt;Date&lt;/b&gt;: inserts the current date and time, in the form of dd-MM-yyyy, click the &quot;wrench&quot; button on the right to customize the format.&lt;br /&gt;
&lt;b&gt;Timestamp&lt;/b&gt;: inserts a number, a Unix timestamp, which is the number of seconds passed since 1970-1-1 00:00:00.&lt;br /&gt;
</string>
</property>
<item>
<property name="text">
<string>(number)</string>
</property>
</item>
<item>
<property name="text">
<string>(date)</string>
</property>
</item>
<item>
<property name="text">
<string>(timestamp)</string>
</property>
</item>
<item>
<property name="text">
<string>(none)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="namingOptionsButton">
<property name="icon">
<iconset resource="../lightscreen.qrc">
<normaloff>:/icons/configure</normaloff>:/icons/configure</iconset>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="formatLabel">
<property name="toolTip">
<string>The file format for the screenshot</string>
</property>
<property name="text">
<string>F&amp;ormat:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>formatComboBox</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="formatComboBox">
<item>
<property name="text">
<string>PNG</string>
</property>
</item>
<item>
<property name="text">
<string>JPG</string>
</property>
</item>
<item>
<property name="text">
<string>BMP</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="qualityLabel">
<property name="text">
<string>&amp;Quality:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>qualitySlider</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSlider" name="qualitySlider">
<property name="whatsThis">
<string>This slider goes from 0 to 100. 100 being the highest quality and 0 the lowest.&lt;br&gt;
Quality is related to file size and of course to readability and overall quality of the image.</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="2">
<layout class="QHBoxLayout" name="qualityLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QLabel" name="qualityValueLabel">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>100</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qualityPercentLabel">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>%</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;i&gt;Preview&lt;/i&gt;:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="previewLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="startupGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>System Startup</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="startupCheckBox">
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>&amp;Run Lightscreen at system startup.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="startupHideLayout">
<item>
<spacer name="startupHideSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>15</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="startupHideCheckBox">
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>H&amp;ide the main window.</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="hotkeyTab">
<attribute name="title">
<string>Hotkeys</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="capturesGroupBox">
<property name="title">
<string>Captures</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="screenCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Capture the screen</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="HotkeyWidget" name="screenHotkeyWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="windowCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Capture the current window</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="HotkeyWidget" name="windowHotkeyWidget"/>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="windowPickerCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Capture a chosen window</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="HotkeyWidget" name="windowPickerHotkeyWidget"/>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="areaCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Capture a screen area</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="HotkeyWidget" name="areaHotkeyWidget"/>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="controlGroupBox">
<property name="title">
<string>Lightscreen Control</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="openCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Open the program window</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="HotkeyWidget" name="openHotkeyWidget"/>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="directoryCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Open the directory</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="HotkeyWidget" name="directoryHotkeyWidget"/>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="optionsTab">
<attribute name="title">
<string>Options</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="optionsScrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>375</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
- <y>-137</y>
- <width>358</width>
- <height>597</height>
+ <y>0</y>
+ <width>366</width>
+ <height>653</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="interfaceGroupBox">
<property name="title">
<string>Interface</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="trayCheckBox">
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Sho&amp;w a system tray icon.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="hideCheckBox">
<property name="text">
<string>&amp;Hide Lightscreen while taking a screenshot.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="warnHideCheckBox">
<property name="text">
<string>Warn when hiding without a tra&amp;y icon.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="notifyLayout">
<property name="spacing">
<number>12</number>
</property>
<item>
<widget class="QLabel" name="notifyLabel">
<property name="text">
<string>&amp;Notify with:</string>
</property>
<property name="buddy">
<cstring>messageCheckBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="messageCheckBox">
<property name="whatsThis">
<string>Shows a completion message once the screenshot is saved, clicking this message takes you to the directory where the screenshot was saved.</string>
</property>
<property name="text">
<string>Tray icon Popup</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="playSoundCheckBox">
<property name="text">
<string>&amp;Sound cue</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="languageLayout">
<item>
<widget class="QLabel" name="languageLabel">
<property name="text">
<string>&amp;Language:</string>
</property>
<property name="buddy">
<cstring>languageComboBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="languageComboBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="moreInformationLabel">
<property name="whatsThis">
<string>Click here to go to the Lightscreen homepage to learn more about translations.</string>
</property>
<property name="text">
<string>&lt;a href=&quot;http://lightscreen.sourceforge.net/translation&quot;&gt;More information..&lt;/a&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="languageSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="screenshotsGroupBox">
<property name="title">
<string>Screenshots</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QCheckBox" name="saveAsCheckBox">
<property name="text">
<string>Choose where to save each screenshot (&quot;&amp;Save as&quot;).</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="clipboardCheckBox">
<property name="text">
<string>&amp;Copy the screenshot to the clipboard.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="currentMonitorCheckBox">
<property name="text">
<string>&amp;Grab only the current monitor.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cursorCheckBox">
<property name="text">
<string>Inc&amp;lude the cursor in the screenshot.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="magnifyCheckBox">
<property name="text">
<string>&amp;Magnify around the mouse in Area mode.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="optiPngCheckBox">
<property name="toolTip">
<string>Runs OptiPNG which reduces screenshot file size.</string>
</property>
<property name="text">
<string>O&amp;ptimize PNG screenshots.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="replaceCheckBox">
<property name="text">
<string>Replace screenshots when there's an existing file.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="areaAutocloseCheckBox">
<property name="text">
<string>Snap area screenshots automatically (no resizing).</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="uploadCheckBox">
<property name="text">
<string>Upload all my screenshots automatically.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="delayLabel">
<property name="text">
<string>D&amp;elay:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>delaySpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="delaySpinBox">
<property name="whatsThis">
<string>Selecting anything other than 0 in this option will cause the program to &lt;b&gt;wait&lt;/b&gt; that amount of seconds before taking the screenshot.</string>
</property>
<property name="specialValueText">
<string>none</string>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property>
<property name="suffix">
<string> seconds</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="maximum">
<number>32767</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>114</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
- <widget class="QGroupBox" name="previewCheckBox">
+ <widget class="QGroupBox" name="previewGroupBox">
<property name="title">
<string>Screenshot Previews</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="previewSizeLabel">
<property name="text">
<string>Maximum Size:</string>
</property>
<property name="buddy">
<cstring>previewSizeSpinBox</cstring>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QSpinBox" name="previewSizeSpinBox">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property>
<property name="suffix">
<string notr="true"> px</string>
</property>
<property name="minimum">
<number>200</number>
</property>
<property name="maximum">
<number>800</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>300</number>
</property>
</widget>
</item>
<item row="0" column="4" colspan="4">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>41</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="previewPositionLabel">
<property name="text">
<string>Position:</string>
</property>
<property name="buddy">
<cstring>previewPositionComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="previewPositionComboBox">
<property name="currentIndex">
<number>3</number>
</property>
<item>
<property name="text">
<string>Top Left</string>
</property>
</item>
<item>
<property name="text">
<string>Top Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Right</string>
</property>
</item>
</widget>
</item>
<item row="1" column="4" colspan="4">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>4</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="previewAutocloseCheckBox">
<property name="text">
<string>Auto-close after</string>
</property>
</widget>
</item>
<item row="2" column="3" colspan="2">
<widget class="QSpinBox" name="previewAutocloseTimeSpinBox">
<property name="suffix">
<string> seconds</string>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QLabel" name="andLabel">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string> and </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="6">
<widget class="QComboBox" name="previewAutocloseActionComboBox">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>save</string>
</property>
</item>
<item>
<property name="text">
<string>cancel</string>
</property>
</item>
</widget>
</item>
<item row="2" column="7">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>23</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="updaterGroupBox">
<property name="title">
<string>Updater</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="updaterCheckBox">
<property name="text">
<string>Check for updates regularly.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="checkUpdatesPushButton">
<property name="text">
<string>Chec&amp;k Updates Now</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="aboutTab">
<attribute name="title">
<string>About</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="mainLabel">
<property name="text">
<string>Lightscreen is a simple tool to take screenshots, designed to be customizable and lightweight.&lt;br&gt;&lt;br&gt;
Created by &lt;a href=&quot;http://ckaiser.com.ar&quot;&gt;Christian Kaiser&lt;/a&gt;, using the &lt;a href=&quot;#aboutqt&quot;&gt;Qt toolkit&lt;/a&gt; for the graphical user interface.&lt;br&gt;&lt;br&gt;
Released under the &lt;a href=&quot;http://www.gnu.org/licenses/gpl-2.0.html&quot;&gt;GNU General Public License&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
Special thanks goes to the &lt;a href=&quot;http://lightscreen.sourceforge.net/about&quot;&gt;Donators and Translators&lt;/a&gt;.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="versionLabel">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="linksLabel">
<property name="text">
<string>&lt;a href=&quot;https://sourceforge.net/projects/lightscreen/&quot;&gt;Visit Sourceforge project site&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://lightscreen.sourceforge.net/&quot;&gt;Visit Lightscreen home page&lt;/a&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HotkeyWidget</class>
<extends>QPushButton</extends>
<header>widgets/hotkeywidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>fileGroupBox</tabstop>
<tabstop>targetLineEdit</tabstop>
<tabstop>browsePushButton</tabstop>
<tabstop>prefixLineEdit</tabstop>
<tabstop>namingComboBox</tabstop>
<tabstop>namingOptionsButton</tabstop>
<tabstop>formatComboBox</tabstop>
<tabstop>qualitySlider</tabstop>
<tabstop>startupCheckBox</tabstop>
<tabstop>startupHideCheckBox</tabstop>
<tabstop>screenCheckBox</tabstop>
<tabstop>screenHotkeyWidget</tabstop>
<tabstop>windowCheckBox</tabstop>
<tabstop>windowHotkeyWidget</tabstop>
<tabstop>windowPickerCheckBox</tabstop>
<tabstop>windowPickerHotkeyWidget</tabstop>
<tabstop>areaCheckBox</tabstop>
<tabstop>areaHotkeyWidget</tabstop>
<tabstop>openCheckBox</tabstop>
<tabstop>openHotkeyWidget</tabstop>
<tabstop>directoryCheckBox</tabstop>
<tabstop>directoryHotkeyWidget</tabstop>
<tabstop>trayCheckBox</tabstop>
<tabstop>hideCheckBox</tabstop>
<tabstop>warnHideCheckBox</tabstop>
<tabstop>messageCheckBox</tabstop>
<tabstop>playSoundCheckBox</tabstop>
<tabstop>languageComboBox</tabstop>
<tabstop>saveAsCheckBox</tabstop>
<tabstop>clipboardCheckBox</tabstop>
<tabstop>currentMonitorCheckBox</tabstop>
<tabstop>cursorCheckBox</tabstop>
<tabstop>magnifyCheckBox</tabstop>
<tabstop>optiPngCheckBox</tabstop>
<tabstop>replaceCheckBox</tabstop>
<tabstop>areaAutocloseCheckBox</tabstop>
<tabstop>delaySpinBox</tabstop>
- <tabstop>previewCheckBox</tabstop>
+ <tabstop>previewGroupBox</tabstop>
<tabstop>previewSizeSpinBox</tabstop>
<tabstop>previewPositionComboBox</tabstop>
<tabstop>previewAutocloseCheckBox</tabstop>
<tabstop>previewAutocloseTimeSpinBox</tabstop>
<tabstop>previewAutocloseActionComboBox</tabstop>
<tabstop>updaterCheckBox</tabstop>
<tabstop>checkUpdatesPushButton</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../lightscreen.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OptionsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>307</x>
<y>304</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>previewAutocloseCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>previewAutocloseTimeSpinBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>118</x>
<y>511</y>
</hint>
<hint type="destinationlabel">
<x>210</x>
<y>529</y>
</hint>
</hints>
</connection>
<connection>
<sender>previewAutocloseCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>previewAutocloseActionComboBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>115</x>
<y>511</y>
</hint>
<hint type="destinationlabel">
<x>302</x>
<y>529</y>
</hint>
</hints>
</connection>
</connections>
</ui>
diff --git a/tools/screenshot.cpp b/tools/screenshot.cpp
index b3998be..580685c 100644
--- a/tools/screenshot.cpp
+++ b/tools/screenshot.cpp
@@ -1,377 +1,390 @@
/*
* Copyright (C) 2011 Christian Kaiser
*
* 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <QApplication>
#include <QClipboard>
#include <QDateTime>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QPainter>
#include <QPixmap>
#include <QDebug>
-#if defined(Q_WS_WIN)
- #include <windows.h>
- #include "windowpicker.h"
-#endif
-
+#include "windowpicker.h"
#include "../dialogs/areadialog.h"
#include "screenshot.h"
#include "os.h"
+
+#ifdef Q_WS_WIN
+ #include <windows.h>
+#endif
+
+#ifdef Q_WS_X11
+ #include <QX11Info>
+ #include <X11/X.h>
+ #include <X11/Xlib.h>
+#endif
+
Screenshot::Screenshot(QObject *parent, Screenshot::Options options):
QObject(parent),
mOptions(options),
mPixmapDelay(false),
mUnloaded(false),
mUnloadFilename()
{
// Here be crickets
}
Screenshot::~Screenshot()
{
if (mUnloaded) {
QFile::remove(mUnloadFilename);
}
}
-Screenshot::Options Screenshot::options()
+Screenshot::Options Screenshot::options() const
{
return mOptions;
}
QPixmap &Screenshot::pixmap()
{
return mPixmap;
}
void Screenshot::activeWindow()
{
#if defined(Q_WS_WIN)
HWND fWindow = GetForegroundWindow();
if (fWindow == NULL)
return;
if (fWindow == GetDesktopWindow()) {
wholeScreen();
return;
}
mPixmap = os::grabWindow(GetForegroundWindow());
-#else
- wholeScreen(); //TODO
+#endif
+
+#if defined(Q_WS_X11)
+ Display *display;
+ Window focus;
+ int revert;
+
+ display = XOpenDisplay(NULL);
+ XGetInputFocus(display, &focus, &revert);
+
+ mPixmap = QPixmap::grabWindow(focus);
#endif
}
QString Screenshot::getName(NamingOptions options, QString prefix, QDir directory)
{
QString naming;
int naming_largest = 0;
if (options.flip) {
naming = "%1" + prefix;
}
else {
naming = prefix + "%1";
}
switch (options.naming)
{
case Screenshot::Numeric: // Numeric
// Iterating through the folder to find the largest numeric naming.
foreach(QString file, directory.entryList(QDir::Files))
{
if (file.contains(prefix)) {
file.chop(file.size() - file.lastIndexOf("."));
file.remove(prefix);
if (file.toInt()> naming_largest) {
naming_largest = file.toInt();
}
}
}
if (options.leadingZeros > 0) {
//Pretty, huh?
QString format;
QTextStream (&format) << "%0" << (options.leadingZeros+1) << "d";
naming = naming.arg(QString().sprintf(format.toAscii(), naming_largest + 1));
}
else {
naming = naming.arg(naming_largest + 1);
}
break;
case Screenshot::Date: // Date
naming = naming.arg(QDateTime::currentDateTime().toString(options.dateFormat));
break;
case Screenshot::Timestamp: // Timestamp
naming = naming.arg(QDateTime::currentDateTime().toTime_t());
break;
- case Screenshot::None:
+ case Screenshot::Empty:
naming = naming.arg("");
break;
}
return naming;
}
QString Screenshot::newFileName()
{
if (!mOptions.directory.exists())
mOptions.directory.mkpath(mOptions.directory.path());
QString naming = Screenshot::getName(mOptions.namingOptions, mOptions.prefix, mOptions.directory);
QString fileName;
QString path = QDir::toNativeSeparators(mOptions.directory.path());
// Cleanup
if (path.at(path.size()-1) != QDir::separator() && !path.isEmpty())
path.append(QDir::separator());
fileName.append(path);
fileName.append(naming);
return fileName;
}
QString Screenshot::extension()
{
switch (mOptions.format) {
case Screenshot::PNG:
return ".png";
break;
case Screenshot::BMP:
return ".bmp";
break;
case Screenshot::JPEG:
default:
return ".jpg";
break;
}
}
void Screenshot::selectedArea()
{
grabDesktop();
if (mPixmap.isNull())
return;
AreaDialog selector(this);
int result = selector.exec();
if (result == QDialog::Accepted) {
mPixmap = mPixmap.copy(selector.resultRect());
}
else {
mPixmap = QPixmap();
}
}
void Screenshot::selectedWindow()
{
-#if defined(Q_WS_WIN)
WindowPicker* windowPicker = new WindowPicker;
mPixmapDelay = true;
connect(windowPicker, SIGNAL(pixmap(QPixmap)), this, SLOT(setPixmap(QPixmap)));
-#else
- wholeScreen();
-#endif
}
void Screenshot::wholeScreen()
{
grabDesktop();
}
void Screenshot::grabDesktop()
{
QRect geometry;
if (mOptions.currentMonitor) {
geometry = qApp->desktop()->screenGeometry(QCursor::pos());
}
else {
geometry = qApp->desktop()->geometry();
}
mPixmap = QPixmap::grabWindow(qApp->desktop()->winId(), geometry.x(), geometry.y(), geometry.width(), geometry.height());
if (mOptions.cursor && !mPixmap.isNull()) {
QPainter painter(&mPixmap);
painter.drawPixmap(QCursor::pos(), os::cursor());
}
}
void Screenshot::take()
{
switch (mOptions.mode)
{
case Screenshot::WholeScreen:
wholeScreen();
break;
case Screenshot::SelectedArea:
selectedArea();
break;
case Screenshot::ActiveWindow:
activeWindow();
break;
case Screenshot::SelectedWindow:
selectedWindow();
break;
}
if (mPixmapDelay)
return;
if (mPixmap.isNull()) {
confirm(false);
}
else {
confirmation();
}
}
void Screenshot::confirm(bool result)
{
if (result) {
save();
}
else {
mOptions.result = Screenshot::Cancel;
}
mPixmap = QPixmap(); // Cleanup just in case.
emit finished();
}
void Screenshot::discard()
{
confirm(false);
}
void Screenshot::save()
{
QString name = "";
QString fileName = "";
Screenshot::Result result = Screenshot::Fail;
if (mOptions.file && !mOptions.saveAs) {
name = newFileName();
}
else if (mOptions.file && mOptions.saveAs) {
name = QFileDialog::getSaveFileName(0, tr("Save as.."), newFileName(), "*" + extension());
}
if (!mOptions.replace && QFile::exists(name+extension())) {
// Ugly? You should see my wife!
int count = 0;
int cunt = 0;
QString naming = QFileInfo(name).fileName();
foreach(QString file, QFileInfo(name+extension()).dir().entryList(QDir::Files)) {
if (file.contains(naming)) {
file.remove(naming);
file.remove(" (");
file.remove(")");
file.remove(extension());
cunt = file.toInt();
if (cunt > count) {
count = cunt;
}
}
}
name = name + " (" + QString::number(count+1) + ")";
}
fileName = name + extension();
+ // In the following code I use (Screenshot::Result)1 instead of Screenshot::Success because of some weird issue with the X11 headers. //TODO
if (mOptions.file) {
if (fileName.isEmpty()) {
result = Screenshot::Fail;
}
else if (mUnloaded) {
- result = (QFile::rename(mUnloadFilename, fileName)) ? Screenshot::Success : Screenshot::Fail;
+ result = (QFile::rename(mUnloadFilename, fileName)) ? (Screenshot::Result)1: Screenshot::Fail;
}
else if (mPixmap.save(fileName, 0, mOptions.quality)) {
- result = Screenshot::Success;
+ result = (Screenshot::Result)1;
}
else {
result = Screenshot::Fail;
}
os::addToRecentDocuments(fileName);
}
if (mOptions.clipboard) {
QApplication::clipboard()->setPixmap(mPixmap, QClipboard::Clipboard);
if (!mOptions.file) {
- result = Screenshot::Success;
+ result = (Screenshot::Result)1;
}
}
mPixmap = QPixmap();
mOptions.fileName = fileName;
mOptions.result = result;
}
void Screenshot::setPixmap(QPixmap pixmap)
{
mPixmap = pixmap;
if (mPixmap.isNull()) {
emit confirm(false);
}
else {
confirmation();
}
}
void Screenshot::confirmation()
{
emit askConfirmation();
if (!mOptions.file) {
return;
}
// Unloading the pixmap to reduce memory usage during previews
mUnloadFilename = mOptions.directory.path() + QDir::separator() + QString("lstemp.%1%2").arg(qrand() * qrand() + QDateTime::currentDateTime().toTime_t()).arg(extension());
mUnloaded = mPixmap.save(mUnloadFilename, 0, mOptions.quality);
if (mUnloaded) {
mPixmap = QPixmap();
}
}
diff --git a/tools/screenshot.h b/tools/screenshot.h
index 504357a..5de2333 100644
--- a/tools/screenshot.h
+++ b/tools/screenshot.h
@@ -1,130 +1,130 @@
/*
* Copyright (C) 2011 Christian Kaiser
*
* 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
#include <QObject>
#include <QDir>
#include <QPixmap>
class Screenshot : public QObject
{
Q_OBJECT
public:
enum Format
{
PNG = 0,
JPEG = 1,
BMP = 2,
TIFF = 3
};
enum Naming
{
Numeric = 0,
Date = 1,
Timestamp = 2,
- None = 3
+ Empty = 3
};
enum Mode
{
WholeScreen = 0,
ActiveWindow = 1,
SelectedArea = 2,
SelectedWindow = 3
};
enum Result
{
Fail = 0,
Success = 1,
Cancel = 2
};
struct NamingOptions
{
Naming naming;
bool flip;
int leadingZeros;
QString dateFormat;
};
struct Options
{
QString fileName;
Result result;
Format format;
QString prefix;
NamingOptions namingOptions;
QDir directory;
int mode;
int quality;
bool currentMonitor;
bool clipboard;
bool file;
bool preview;
bool magnify;
bool cursor;
bool saveAs;
bool animations;
bool replace;
};
Screenshot(QObject *parent, Screenshot::Options options);
~Screenshot();
- Screenshot::Options options();
+ Screenshot::Options options() const;
QPixmap &pixmap();
static QString getName(NamingOptions options, QString prefix, QDir directory);
public slots:
void take();
void confirm(bool result = true);
void discard();
void save();
void setPixmap(QPixmap pixmap);
void confirmation();
signals:
void askConfirmation();
void finished();
private:
void activeWindow();
QString newFileName();
QString extension();
void selectedArea();
void selectedWindow();
void wholeScreen();
void grabDesktop();
private:
Screenshot::Options mOptions;
QPixmap mPixmap;
bool mPixmapDelay;
bool mUnloaded;
QString mUnloadFilename;
};
#endif // SCREENSHOT_H

File Metadata

Mime Type
text/x-diff
Expires
Wed, Jun 17, 9:06 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70970
Default Alt Text
(108 KB)

Event Timeline