[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] make ksnapshot increment the last number
From:       "=?UTF-8?Q?Ho=C3=A0ng_=C4=90=E1=BB=A9c_Hi=E1=BA=BFu?=" <hieu.d.hoang () gmail ! com>
Date:       2007-10-02 2:07:56
Message-ID: 4f12b0dd0710011907r1f9c1d1fvf4b08b5c2cc2ac81 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

  Hi,

 I have been using ksnapshot to record my whiteboarding sessions, and
named the files like "whiteboard-2007-10-02-01.png". Both Ksnapshots
from KDE3 and KDE4 offer the next filename as
"whiteboard-2008-10-02-01.png". IMHO it should increment the last
number in the filename, because the ordering numbers are most likely
placed last.

 On a second note, I want the default numbering to start with "01", so
that sorting tools which don't sort numerically (e.g. ls) show the
first 19 snapshots in increasing order.

 I have attached a patch to use these two behaviour. A previously
created ksnapshotrc file may still specify old default filename
"snapshot1.png".

  Hiếu
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHAafbh4dScvxKz04RAqmLAKCVkLddMR+PsaK+oURi/MHRrENJQQCg1GTu
ZoKvuN3I7w6O5AZsL466SjI=
=UIai
-----END PGP SIGNATURE-----

["ksnapshot-increment-last-number.patch" (text/x-patch)]

Index: KDE/kdegraphics/ksnapshot/ksnapshotobject.cpp
===================================================================
--- KDE/kdegraphics/ksnapshot/ksnapshotobject.cpp	(revision 719619)
+++ KDE/kdegraphics/ksnapshot/ksnapshotobject.cpp	(working copy)
@@ -56,7 +56,7 @@
     QRegExp numSearch("[0-9]+");
 
     // Does it have a number?
-    int start = numSearch.indexIn(name);
+    int start = numSearch.lastIndexIn(name);
     if (start != -1) {
         // It has a number, increment it
         int len = numSearch.matchedLength();
Index: KDE/kdegraphics/ksnapshot/kbackgroundsnapshot.cpp
===================================================================
--- KDE/kdegraphics/ksnapshot/kbackgroundsnapshot.cpp	(revision 719619)
+++ KDE/kdegraphics/ksnapshot/kbackgroundsnapshot.cpp	(working copy)
@@ -90,7 +90,7 @@
 
 void KBackgroundSnapshot::savePictureOnDesktop()
 {
-    filename = KUrl( KGlobalSettings::desktopPath()+i18n("snapshot")+"1.png" );
+    filename = KUrl( KGlobalSettings::desktopPath()+i18n("snapshot")+"01.png" );
     // Make sure the name is not already being used
     while(KIO::NetAccess::exists( filename, KIO::NetAccess::DestinationSide, 0L )) {
         autoincFilename();
Index: KDE/kdegraphics/ksnapshot/ksnapshot.cpp
===================================================================
--- KDE/kdegraphics/ksnapshot/ksnapshot.cpp	(revision 719619)
+++ KDE/kdegraphics/ksnapshot/ksnapshot.cpp	(working copy)
@@ -152,7 +152,7 @@
     setDelay( conf.readEntry("delay", 0) );
     setMode( conf.readEntry("mode", 0) );
     setIncludeDecorations(conf.readEntry("includeDecorations",true));
-    filename = KUrl( conf.readPathEntry( "filename", \
QDir::currentPath()+'/'+i18n("snapshot")+"1.png" )); +    filename = KUrl( \
conf.readPathEntry( "filename", QDir::currentPath()+'/'+i18n("snapshot")+"01.png" )); \
  // Make sure the name is not already being used
     while(KIO::NetAccess::exists( filename, KIO::NetAccess::DestinationSide, this )) \
{



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic