Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Sep 9, 2017
2 parents 7362b26 + a2fd1a9 commit ae63eb8
Show file tree
Hide file tree
Showing 23 changed files with 516 additions and 266 deletions.
32 changes: 32 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
v3.0.4
- Add "Paste current date and time" predefined command
- Add "Take screenshot" predefined command
- Add scriptable function queryKeyboardModifiers()
- Add scriptable function screenNames()
- Add scriptable function isClipboard()
- Add scriptable function toggleConfig()
- Expand text ellipsis if selected
- Avoid copying ellipsis if selected and copy rich text only if needed
- Fix item rendering on high DPI screens
- Fix tray icon on high DPI screens
- Fix taking screenshots on multiple monitors and on high DPI screens
- Fix flicker when rendering items for the first time
- Fix icon layout for notes
- Fix showing icon if notes are empty
- Fix copying/drag'n'dropping files into a synchronized tab
- Fix long message alignment in notifications
- Fix activating simple items with double-click
- Fix styling of current and selected items
- Fix setting clipboard immediately after start
- Fix size of items with tags
- Fix moving multiple items to clipboard and to the top of the list
- Fix updating global shortcuts with setCommands()
- Fix clearing search after opening internal editor
- OSX: Fix some memory leaks
- Linux: Fix getting icon for non-default session from theme
- Linux: Fix settings tab name in KDE/Plasma
- Windows: Add pinned items to installer
- Windows: Fix saving tab with another plugin
- Windows: Fix pasting to a window
- Windows: Fix setting foreground window even if app is in background

v3.0.3
- Added new documentation
- Added option to disable auto-completion for commands
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ For unlisted systems, please follow the instructions in

### Windows

On Windows you can install the copyq [Chocolatey package](https://chocolatey.org/packages/copyq).
On Windows you either use installer ([setup.exe](https://github.com/hluk/CopyQ/releases)),
portable [zip](https://github.com/hluk/CopyQ/releases)
or you can install the copyq [Chocolatey package](https://chocolatey.org/packages/copyq).

```
choco install copyq
Expand Down
46 changes: 44 additions & 2 deletions docs/scripting-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ omitted.

Same as ``hasClipboardFormat()`` for Linux/X11 mouse selection.

.. js:function:: bool isClipboard()

Returns true only in automatic command triggered by clipboard change.

This can be used to check if current automatic command was triggered by
clipboard and not Linux/X11 mouse selection change.

.. js:function:: bool copy(text)

Sets clipboard plain text.
Expand Down Expand Up @@ -405,6 +412,10 @@ omitted.
Throws an exception if there is an invalid option in which case it won't
set any options.

.. js:function:: bool toggleConfig(optionName)

Toggles an option (true to false and vice versa) and returns the new value.

.. js:function:: String info([pathName])

Returns paths and flags used by the application.
Expand Down Expand Up @@ -794,6 +805,10 @@ omitted.

Returns image data with screenshot.

Default ``screenName`` is name of the screen with mouse cursor.

You can list valid values for ``screenName`` with ``screenNames()``.

Example:

.. code-block:: js
Expand All @@ -804,6 +819,10 @@ omitted.

Same as ``screenshot()`` but allows to select an area on screen.

.. js:function:: String[] screenNames()

Returns list of available screen names.

.. js:function:: String[] queryKeyboardModifiers()

Returns list of currently pressed keyboard modifiers which can be 'Ctrl', 'Shift', 'Alt', 'Meta'.
Expand Down Expand Up @@ -834,15 +853,36 @@ Types

See `QFile <http://doc.qt.io/qt-5/qfile.html>`__.

To open file in different modes use:

- `open()` - read/write
- `openReadOnly()` - read only
- `openWriteOnly()` - write only, truncates the file
- `openAppend()` - write only, appends to the file

Following code reads contents of "README.md" file from current
directory.

.. code-block:: js
var f = new File("README.md")
f.open()
var f = new File('README.md')
if (!f.openReadOnly())
raise 'Failed to open the file: ' + f.errorString()
var bytes = f.readAll()
Following code writes to a file in home directory.

.. code-block:: js
var dataToWrite = 'Hello, World!'
var filePath = Dir().homePath() + '/copyq.txt'
var f = new File(filePath)
if (!f.openWriteOnly() || f.write(dataToWrite) == -1)
raise 'Failed to save the file: ' + f.errorString()
// Always flush the data and close the file,
// before opening the file in other application.
f.close()
.. js:class:: Dir

Wrapper for QDir Qt class.
Expand All @@ -862,6 +902,8 @@ Types
f.setAutoRemove(false)
popup('New temporary file', f.fileName())
To open file in different modes, use same open methods as for `File`.

.. js:class:: Item (Object)

Object with MIME types of an item.
Expand Down
49 changes: 38 additions & 11 deletions plugins/itempinned/itempinned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ Command dummyPinCommand()
return c;
}

bool containsPinnedItems(const QModelIndexList &indexList)
{
return std::any_of( std::begin(indexList), std::end(indexList), isPinned );
}

} // namespace

ItemPinned::ItemPinned(ItemWidget *childItem)
Expand Down Expand Up @@ -207,10 +212,7 @@ bool ItemPinnedSaver::saveItems(const QString &tabName, const QAbstractItemModel

bool ItemPinnedSaver::canRemoveItems(const QList<QModelIndex> &indexList, QString *error)
{
const bool containsPinnedItems = std::any_of(
std::begin(indexList), std::end(indexList), isPinned);

if (!containsPinnedItems)
if ( !containsPinnedItems(indexList) )
return m_saver->canRemoveItems(indexList, error);

if (error) {
Expand All @@ -227,7 +229,8 @@ bool ItemPinnedSaver::canRemoveItems(const QList<QModelIndex> &indexList, QStrin

bool ItemPinnedSaver::canMoveItems(const QList<QModelIndex> &indexList)
{
return m_saver->canMoveItems(indexList);
return !containsPinnedItems(indexList)
&& m_saver->canMoveItems(indexList);
}

void ItemPinnedSaver::itemsRemovedByUser(const QList<QModelIndex> &indexList)
Expand Down Expand Up @@ -284,16 +287,40 @@ void ItemPinnedSaver::onRowsRemoved(const QModelIndex &, int start, int end)

void ItemPinnedSaver::onRowsMoved(const QModelIndex &, int start, int end, const QModelIndex &, int destinationRow)
{
if ( (m_lastPinned < start && m_lastPinned < destinationRow)
|| (end < m_lastPinned && destinationRow < m_lastPinned) )
if (!m_model)
return;

if ( (m_lastPinned >= start || m_lastPinned >= destinationRow)
&& (end >= m_lastPinned || destinationRow >= m_lastPinned) )
{
if (start < destinationRow)
updateLastPinned(start, destinationRow + end - start + 1);
else
updateLastPinned(destinationRow, end);
}

if (destinationRow != 0 || start < destinationRow)
return;

const int rowCount = end - start + 1;

for (int row = destinationRow; row < destinationRow + rowCount; ++row) {
if ( isPinned(m_model->index(row, 0)) )
return;
}

if (start < destinationRow)
updateLastPinned(start, destinationRow + end - start + 1);
else
updateLastPinned(destinationRow, end);
disconnect( m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
this, SLOT(onRowsMoved(QModelIndex,int,int,QModelIndex,int)) );

// Shift rows below inserted up.
for (int row = destinationRow + rowCount; row <= std::min(m_lastPinned, end); ++row) {
const auto index = m_model->index(row, 0);
if ( isPinned(index) )
moveRow(row, row - rowCount);
}

connect( m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
SLOT(onRowsMoved(QModelIndex,int,int,QModelIndex,int)) );
}

void ItemPinnedSaver::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Expand Down
8 changes: 7 additions & 1 deletion plugins/itemtags/itemtags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,13 @@ class TagTableWidgetItem : public QTableWidgetItem
if ( isTagValid(tag) ) {
QWidget tagWidget;
initTagWidget(&tagWidget, tag, smallerFont(QFont()));
m_pixmap = QPixmap(tagWidget.sizeHint());
#if QT_VERSION < 0x050000
m_pixmap = QPixmap( tagWidget.sizeHint() );
#else
const auto ratio = tagWidget.devicePixelRatio();
m_pixmap = QPixmap( tagWidget.sizeHint() * ratio );
m_pixmap.setDevicePixelRatio(ratio);
#endif
m_pixmap.fill(Qt::transparent);
QPainter painter(&m_pixmap);
tagWidget.render(&painter);
Expand Down

0 comments on commit ae63eb8

Please sign in to comment.